diff --git a/pubspec.lock b/pubspec.lock index c9dd08c4c..7fbe1384c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -36,7 +36,7 @@ packages: guinness: description: guinness source: hosted - version: "0.1.5" + version: "0.1.6" html5lib: description: html5lib source: hosted diff --git a/pubspec.yaml b/pubspec.yaml index 55dbfe073..2f425b2ef 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -29,4 +29,4 @@ dev_dependencies: benchmark_harness: '>=1.0.0' unittest: '>=0.10.1 <0.12.0' mock: '>=0.10.0 <0.12.0' - guinness: '>=0.1.3 <0.2.0' + guinness: '>=0.1.6 <0.2.0' diff --git a/test/angular_spec.dart b/test/angular_spec.dart index def7303c1..e2e69a6a5 100644 --- a/test/angular_spec.dart +++ b/test/angular_spec.dart @@ -12,7 +12,7 @@ main() { expect(() { dynamic v = 6; String s = v; - }).toThrow(); + }).toThrowWith(); }); }); @@ -40,7 +40,7 @@ main() { it('should fail with not enough arguments', () { expect(() { relaxFnApply((required, alsoRequired) => "happy", [1]); - }).toThrow('Unknown function type, expecting 0 to 5 args.'); + }).toThrowWith(message: 'Unknown function type, expecting 0 to 5 args.'); }); }); diff --git a/test/change_detection/watch_group_spec.dart b/test/change_detection/watch_group_spec.dart index cf1a8ac42..db6bb46a4 100644 --- a/test/change_detection/watch_group_spec.dart +++ b/test/change_detection/watch_group_spec.dart @@ -292,7 +292,7 @@ void main() { watchLast.remove(); expect(watchGrp.fieldCost).toEqual(0); - expect(() => watch.remove()).toThrow('Already deleted!'); + expect(() => watch.remove()).toThrowWith(message: 'Already deleted!'); }); it('should eval pure FunctionApply', () { diff --git a/test/core/core_directive_spec.dart b/test/core/core_directive_spec.dart index ab4cd3149..5a91dc0ef 100644 --- a/test/core/core_directive_spec.dart +++ b/test/core/core_directive_spec.dart @@ -52,8 +52,8 @@ void main() { var injector = applicationFactory().addModule(module).createInjector(); expect(() { injector.get(DirectiveMap); - }).toThrow('Mapping for attribute foo is already defined (while ' - 'processing annottation for field foo of Bad1Component)'); + }).toThrowWith(message: 'Mapping for attribute foo is already defined (while ' + 'processing annottation for field foo of Bad1Component)'); }); it('should throw when annotated both getter and setter', () { @@ -63,8 +63,8 @@ void main() { var injector = applicationFactory().addModule(module).createInjector(); expect(() { injector.get(DirectiveMap); - }).toThrow('Attribute annotation for foo is defined more than once ' - 'in Bad2Component'); + }).toThrowWith(message: 'Attribute annotation for foo is defined more than once ' + 'in Bad2Component'); }); }); diff --git a/test/core/parser/lexer_spec.dart b/test/core/parser/lexer_spec.dart index 8ccbc2669..7333b725f 100644 --- a/test/core/parser/lexer_spec.dart +++ b/test/core/parser/lexer_spec.dart @@ -225,11 +225,11 @@ main() { it('should throws exception for invalid exponent', () { expect(() { lex("0.5E-"); - }).toThrow('Lexer Error: Invalid exponent at column 4 in expression [0.5E-]'); + }).toThrowWith(message: 'Lexer Error: Invalid exponent at column 4 in expression [0.5E-]'); expect(() { lex("0.5E-A"); - }).toThrow('Lexer Error: Invalid exponent at column 4 in expression [0.5E-A]'); + }).toThrowWith(message: 'Lexer Error: Invalid exponent at column 4 in expression [0.5E-A]'); }); it('should tokenize number starting with a dot', () { @@ -240,7 +240,8 @@ main() { it('should throw error on invalid unicode', () { expect(() { lex("'\\u1''bla'"); - }).toThrow("Lexer Error: Invalid unicode escape [\\u1''b] at column 2 in expression ['\\u1''bla']"); + }).toThrowWith(message: "Lexer Error: Invalid unicode escape [\\u1''b] at column 2 in " + "expression ['\\u1''bla']"); }); }); } diff --git a/test/core/parser/parser_spec.dart b/test/core/parser/parser_spec.dart index 60ecd68dc..18d7c5312 100644 --- a/test/core/parser/parser_spec.dart +++ b/test/core/parser/parser_spec.dart @@ -170,111 +170,115 @@ main() { // PARSER ERRORS it('should throw a reasonable error for unconsumed tokens', () { - expectEval(")").toThrow('Parser Error: Unconsumed token ) at column 1 in [)]'); + expectEval(")").toThrowWith(message: 'Parser Error: Unconsumed token ) at column 1 in [)]'); }); it('should throw on missing expected token', () { - expectEval("a(b").toThrow('Parser Error: Missing expected ) the end of the expression [a(b]'); + expectEval("a(b").toThrowWith(message: 'Parser Error: Missing expected ) the end of the ' + 'expression [a(b]'); }); it('should throw on bad assignment', () { - expectEval("5=4").toThrow('Parser Error: Expression 5 is not assignable at column 2 in [5=4]'); - expectEval("array[5=4]").toThrow('Parser Error: Expression 5 is not assignable at column 8 in [array[5=4]]'); + expectEval("5=4").toThrowWith(message: 'Parser Error: Expression 5 is not assignable at ' + 'column 2 in [5=4]'); + expectEval("array[5=4]").toThrowWith(message: 'Parser Error: Expression 5 is not assignable' + ' at column 8 in [array[5=4]]'); }); it('should throw on incorrect ternary operator syntax', () { - expectEval("true?1").toThrow('Parser Error: Conditional expression true?1 requires all 3 expressions'); + expectEval("true?1").toThrowWith(message: 'Parser Error: Conditional expression true?1 ' + 'requires all 3 expressions'); }); it('should throw on non-function function calls', () { - expectEval("4()").toThrow('4 is not a function'); + expectEval("4()").toThrowWith(message: '4 is not a function'); }); it("should throw on an unexpected token", (){ - expectEval("[1,2] trac") - .toThrow('Parser Error: \'trac\' is an unexpected token at column 7 in [[1,2] trac]'); + expectEval("[1,2] trac").toThrowWith(message: 'Parser Error: \'trac\' is an unexpected ' + 'token at column 7 in [[1,2] trac]'); }); it('should fail gracefully when invoking non-function', () { expect(() { parser('a[0]()').eval({'a': [4]}); - }).toThrow('a[0] is not a function'); + }).toThrowWith(message: 'a[0] is not a function'); expect(() { parser('a[x()]()').eval({'a': [4], 'x': () => 0}); - }).toThrow('a[x()] is not a function'); + }).toThrowWith(message: 'a[x()] is not a function'); expect(() { parser('{}()').eval({}); - }).toThrow('{} is not a function'); + }).toThrowWith(message: '{} is not a function'); }); it('should throw on undefined functions (relaxed message)', () { - expectEval("notAFn()").toThrow('notAFn'); + expectEval("notAFn()").toThrowWith(message: 'notAFn'); }); it('should fail gracefully when missing a function (relaxed message)', () { expect(() { parser('doesNotExist()').eval({}); - }).toThrow('doesNotExist'); + }).toThrowWith(message: 'doesNotExist'); expect(() { parser('exists(doesNotExist())').eval({'exists': () => true}); - }).toThrow('doesNotExist'); + }).toThrowWith(message: 'doesNotExist'); expect(() { parser('doesNotExists(exists())').eval({'exists': () => true}); - }).toThrow('doesNotExist'); + }).toThrowWith(message: 'doesNotExist'); expect(() { parser('doesNotExist(1)').eval({}); - }).toThrow('doesNotExist'); + }).toThrowWith(message: 'doesNotExist'); expect(() { parser('doesNotExist(1, 2)').eval({}); - }).toThrow('doesNotExist'); + }).toThrowWith(message: 'doesNotExist'); expect(() { parser('doesNotExist()').eval(new TestData()); - }).toThrow('doesNotExist'); + }).toThrowWith(message: 'doesNotExist'); expect(() { parser('doesNotExist(1)').eval(new TestData()); - }).toThrow('doesNotExist'); + }).toThrowWith(message: 'doesNotExist'); expect(() { parser('doesNotExist(1, 2)').eval(new TestData()); - }).toThrow('doesNotExist'); + }).toThrowWith(message: 'doesNotExist'); expect(() { parser('a.doesNotExist()').eval({'a': {}}); - }).toThrow('doesNotExist'); + }).toThrowWith(message: 'doesNotExist'); expect(() { parser('a.doesNotExist(1)').eval({'a': {}}); - }).toThrow('doesNotExist'); + }).toThrowWith(message: 'doesNotExist'); expect(() { parser('a.doesNotExist(1, 2)').eval({'a': {}}); - }).toThrow('doesNotExist'); + }).toThrowWith(message: 'doesNotExist'); expect(() { parser('a.doesNotExist()').eval({'a': new TestData()}); - }).toThrow('doesNotExist'); + }).toThrowWith(message: 'doesNotExist'); expect(() { parser('a.doesNotExist(1)').eval({'a': new TestData()}); - }).toThrow('doesNotExist'); + }).toThrowWith(message: 'doesNotExist'); expect(() { parser('a.doesNotExist(1, 2)').eval({'a': new TestData()}); - }).toThrow('doesNotExist'); + }).toThrowWith(message: 'doesNotExist'); }); @@ -283,7 +287,7 @@ main() { expect(eval('null')).toBe(null); expect(() => eval('map.null')) - .toThrow("Identifier 'null' is a reserved word."); + .toThrowWith(message: "Identifier 'null' is a reserved word."); }); @@ -309,14 +313,14 @@ main() { it('should pass exceptions through getters', () { expect(() { parser('boo').eval(new ScopeWithErrors()); - }).toThrow('boo to you'); + }).toThrowWith(message: 'boo to you'); }); it('should pass noSuchMethodExceptions through getters', () { expect(() { parser('getNoSuchMethod').eval(new ScopeWithErrors()); - }).toThrow("null"); + }).toThrowWith(message: "null"); // Dartium throws: The null object does not have a method 'iDontExist' // Chrome throws: NullError: Cannot call "iDontExist$0" on null // Firefox throws: NullError: null has no properties @@ -326,14 +330,14 @@ main() { it('should pass exceptions through methods', () { expect(() { parser('foo()').eval(new ScopeWithErrors()); - }).toThrow('foo to you'); + }).toThrowWith(message: 'foo to you'); }); it('should fail if reflected object has no property', () { expect(() { parser('notAProperty').eval(new TestData()); - }).toThrow("notAProperty"); + }).toThrowWith(message: "notAProperty"); }); @@ -344,27 +348,29 @@ main() { // On dart2js with reflection: ArgumentError: private identifier" expect(() { parser('_privateField').eval(new WithPrivateField()); - }).toThrow(); + }).toThrowWith(); }); it('should only allow identifier or keyword as formatter names', () { - expect(() => parser('"Foo"|(')).toThrow('identifier or keyword'); - expect(() => parser('"Foo"|1234')).toThrow('identifier or keyword'); - expect(() => parser('"Foo"|"uppercase"')).toThrow('identifier or keyword'); + expect(() => parser('"Foo"|(')).toThrowWith(message: 'identifier or keyword'); + expect(() => parser('"Foo"|1234')).toThrowWith(message: 'identifier or keyword'); + expect(() => parser('"Foo"|"uppercase"')).toThrowWith(message: 'identifier or keyword'); }); it('should only allow identifier or keyword as member names', () { - expect(() => parser('x.(')).toThrow('identifier or keyword'); - expect(() => parser('x. 1234')).toThrow('identifier or keyword'); - expect(() => parser('x."foo"')).toThrow('identifier or keyword'); + expect(() => parser('x.(')).toThrowWith(message: 'identifier or keyword'); + expect(() => parser('x. 1234')).toThrowWith(message: 'identifier or keyword'); + expect(() => parser('x."foo"')).toThrowWith(message: 'identifier or keyword'); }); it('should only allow identifier, string, or keyword as object literal key', () { - expect(() => parser('{(:0}')).toThrow('expected identifier, keyword, or string'); - expect(() => parser('{1234:0}')).toThrow('expected identifier, keyword, or string'); + expect(() => parser('{(:0}')) + .toThrowWith(message: 'expected identifier, keyword, or string'); + expect(() => parser('{1234:0}')) + .toThrowWith(message: 'expected identifier, keyword, or string'); }); }); @@ -440,7 +446,8 @@ main() { context['obj'] = new SetterObject(); expect(() { eval('obj.integer = "hello"'); - }).toThrow("Eval Error: Caught type 'String' is not a subtype of type 'int' of 'value'. while evaling [obj.integer = \"hello\"]"); + }).toThrowWith(message: "Eval Error: Caught type 'String' is not a subtype of type 'int' " + "of 'value'. while evaling [obj.integer = \"hello\"]"); }); }); @@ -467,7 +474,7 @@ main() { for (String reserved in RESERVED_WORDS) { expect(() { parser("o.$reserved()").eval({ 'o': new Object() }); - }).toThrow('Undefined function $reserved'); + }).toThrowWith(message: 'Undefined function $reserved'); expect(parser("o.$reserved()").eval({ 'o': { reserved: () => reserved }})).toEqual(reserved); } }); @@ -498,7 +505,7 @@ main() { if ([ "true", "false", "null"].contains(reserved)) continue; expect(() { parser("$reserved()").eval(new Object()); - }).toThrow('Undefined function $reserved'); + }).toThrowWith(message: 'Undefined function $reserved'); expect(parser("$reserved()").eval({ reserved: () => reserved })).toEqual(reserved); } }); @@ -643,7 +650,7 @@ main() { it('should catch NoSuchMethod', () { context = {'a': {'b': 23}}; - expect(() => eval('a.b.c.d')).toThrow('NoSuchMethod'); + expect(() => eval('a.b.c.d')).toThrowWith(message: 'NoSuchMethod'); }); @@ -815,7 +822,7 @@ main() { it('should throw exception on non-closed bracket', () { expect(() { eval('[].count('); - }).toThrow('Unexpected end of expression: [].count('); + }).toThrowWith(message: 'Unexpected end of expression: [].count('); }); @@ -1057,16 +1064,22 @@ main() { it('should be an error to use the same name twice', () { - expect(() => parser('foo(a: 0, a: 1)')).toThrow("Duplicate argument named 'a' at column 11"); - expect(() => parser('foo(a: 0, b: 1, a: 2)')).toThrow("Duplicate argument named 'a' at column 17"); - expect(() => parser('foo(0, a: 1, a: 2)')).toThrow("Duplicate argument named 'a' at column 14"); - expect(() => parser('foo(0, a: 1, b: 2, a: 3)')).toThrow("Duplicate argument named 'a' at column 20"); + expect(() => parser('foo(a: 0, a: 1)')) + .toThrowWith(message: "Duplicate argument named 'a' at column 11"); + expect(() => parser('foo(a: 0, b: 1, a: 2)')) + .toThrowWith(message: "Duplicate argument named 'a' at column 17"); + expect(() => parser('foo(0, a: 1, a: 2)')) + .toThrowWith(message: "Duplicate argument named 'a' at column 14"); + expect(() => parser('foo(0, a: 1, b: 2, a: 3)')) + .toThrowWith(message: "Duplicate argument named 'a' at column 20"); }); it('should be an error to use Dart reserved words as names', () { - expect(() => parser('foo(if: 0)')).toThrow("Cannot use Dart reserved word 'if' as named argument at column 5"); - expect(() => parser('foo(a: 0, class: 0)')).toThrow("Cannot use Dart reserved word 'class' as named argument at column 11"); + expect(() => parser('foo(if: 0)')) + .toThrowWith(message: "Cannot use Dart reserved word 'if' as named argument at column 5"); + expect(() => parser('foo(a: 0, class: 0)')) + .toThrowWith(message: "Cannot use Dart reserved word 'class' as named argument at column 11"); }); @@ -1128,10 +1141,10 @@ main() { it('should parse formatters', () { expect(() { eval("1|nonexistent"); - }).toThrow('No Formatter: nonexistent found!'); + }).toThrowWith(message: 'No Formatter: nonexistent found!'); expect(() { eval("1|nonexistent", formatters); - }).toThrow('No Formatter: nonexistent found!'); + }).toThrowWith(message: 'No Formatter: nonexistent found!'); context['offset'] = 3; expect(eval("'abcd'|substring:1:offset")).toEqual("bc"); @@ -1142,7 +1155,7 @@ main() { var expression = parser("'World'|hello"); expect(() { expression.eval({}, formatters); - }).toThrow('No Formatter: hello found!'); + }).toThrowWith(message: 'No Formatter: hello found!'); var module = new Module() ..bind(HelloFormatter); @@ -1156,10 +1169,12 @@ main() { it('should not allow formatters in a chain', () { expect(() { parser("1;'World'|hello"); - }).toThrow('Cannot have a formatter in a chain the end of the expression [1;\'World\'|hello]'); + }).toThrowWith(message: 'Cannot have a formatter in a chain the end of the expression ' + '[1;\'World\'|hello]'); expect(() { parser("'World'|hello;1"); - }).toThrow('Cannot have a formatter in a chain at column 15 in [\'World\'|hello;1]'); + }).toThrowWith(message: 'Cannot have a formatter in a chain at column 15 in ' + '[\'World\'|hello;1]'); }); }); }); diff --git a/test/core/scope_spec.dart b/test/core/scope_spec.dart index 704f7b523..32a0220ed 100644 --- a/test/core/scope_spec.dart +++ b/test/core/scope_spec.dart @@ -874,8 +874,8 @@ void main() { it(r'should properly reset phase on exception', (RootScope rootScope) { var error = 'MyError'; - expect(() => rootScope.apply(() { throw error; })).toThrow(error); - expect(() => rootScope.apply(() { throw error; })).toThrow(error); + expect(() => rootScope.apply(() { throw error; })).toThrowWith(message: error); + expect(() => rootScope.apply(() { throw error; })).toThrowWith(message: error); }); }); @@ -963,9 +963,9 @@ void main() { retValue = 2; expect(rootScope.flush). - toThrow('Observer reaction functions should not change model. \n' - 'These watch changes were detected: logger("watch"): 2 <= 1\n' - 'These observe changes were detected: '); + toThrowWith(message: 'Observer reaction functions should not change model. \n' + 'These watch changes were detected: logger("watch"): 2 <= 1\n' + 'These observe changes were detected: '); }); }); @@ -1156,7 +1156,7 @@ void main() { rootScope.watch('name', (a, b) { expect(() { rootScope.digest(); - }).toThrow(r'digest already in progress'); + }).toThrowWith(message: r'digest already in progress'); callCount++; }); rootScope.context['name'] = 'a'; @@ -1219,11 +1219,11 @@ void main() { expect(() { rootScope.digest(); - }).toThrow('Model did not stabilize in 5 digests. ' - 'Last 3 iterations:\n' - 'a: 2 <= 1, b: 2 <= 1\n' - 'a: 3 <= 2, b: 3 <= 2\n' - 'a: 4 <= 3, b: 4 <= 3'); + }).toThrowWith(message: 'Model did not stabilize in 5 digests. ' + 'Last 3 iterations:\n' + 'a: 2 <= 1, b: 2 <= 1\n' + 'a: 3 <= 2, b: 3 <= 2\n' + 'a: 4 <= 3, b: 4 <= 3'); }); diff --git a/test/core/zone_spec.dart b/test/core/zone_spec.dart index e77cd28cc..dabfa1a4f 100644 --- a/test/core/zone_spec.dart +++ b/test/core/zone_spec.dart @@ -33,7 +33,7 @@ void main() { zone.run(() { throw ['hello']; }); - }).toThrow('hello'); + }).toThrowWith(message: 'hello'); expect(error).toEqual(['hello']); }); @@ -74,7 +74,7 @@ void main() { expect(() { zone.run(() { }); - }).toThrow('fromOnTurnDone'); + }).toThrowWith(message: 'fromOnTurnDone'); expect(exceptionHandler.errors.length).toEqual(1); expect(exceptionHandler.errors[0].error).toEqual(["fromOnTurnDone"]); @@ -94,7 +94,7 @@ void main() { asyncRan = true; }); }); - }).toThrow('fromOnTurnDone'); + }).toThrowWith(message: 'fromOnTurnDone'); expect(asyncRan).toBeTruthy(); expect(exceptionHandler.errors.length).toEqual(1); @@ -339,8 +339,8 @@ void main() { expect(() => zone.run(() { log('zone run'); throw 'zoneError'; - })).toThrow('zoneError'); - expect(() => zone.assertInTurn()).toThrow(); + })).toThrowWith(message: 'zoneError'); + expect(() => zone.assertInTurn()).toThrowWith(); expect(log.result()).toEqual('onTurnStart; zone run; onError; onTurnDone'); })); @@ -352,8 +352,8 @@ void main() { }; expect(() => zone.run(() { log('zone run'); - })).toThrow('zoneError'); - expect(() => zone.assertInTurn()).toThrow(); + })).toThrowWith(message: 'zoneError'); + expect(() => zone.assertInTurn()).toThrowWith(); expect(log.result()).toEqual('onTurnStart; onError; onTurnDone'); })); @@ -370,7 +370,7 @@ void main() { microLeap(); - expect(() => zone.assertInTurn()).toThrow(); + expect(() => zone.assertInTurn()).toThrowWith(); expect(log.result()).toEqual('onTurnStart; zone run; scheduleMicrotask; onError; onTurnDone'); })); @@ -401,7 +401,7 @@ void main() { expect(async(() { zone.assertInZone(); microLeap(); - })).toThrow(); + })).toThrowWith(); }); @@ -433,7 +433,7 @@ void main() { expect(async(() { zone.assertInTurn(); microLeap(); - })).toThrow('ssertion'); // Support both dart2js and the VM with half a word. + })).toThrowWith(message: 'ssertion'); // Support both dart2js and the VM with half a word. }); group('microtask scheduler', () { diff --git a/test/core_dom/compiler_spec.dart b/test/core_dom/compiler_spec.dart index fab93e00b..d5a8adfc0 100644 --- a/test/core_dom/compiler_spec.dart +++ b/test/core_dom/compiler_spec.dart @@ -523,7 +523,7 @@ void main() { it('should error on incorrect mapping', async(() { expect(() { _.compile(r'