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'
'); - }).toThrow("Unknown mapping 'foo\' for attribute 'attr'."); + }).toThrowWith(message: "Unknown mapping 'foo\' for attribute 'attr'."); })); it('should support formatters in attribute expressions', async(() { @@ -538,7 +538,8 @@ void main() { it('should error on non-asignable-mapping', async(() { expect(() { _.compile(r'
'); - }).toThrow("Expression '1+2' is not assignable in mapping '@1+2' for attribute 'attr'."); + }).toThrowWith(message: "Expression '1+2' is not assignable in mapping '@1+2' for " + "attribute 'attr'."); })); it('should expose mapped attributes as camel case', async(() { @@ -683,7 +684,7 @@ void main() { var directives = injector.get(DirectiveMap); expect(() { c(es('
'), injector.get(DirectiveMap)); - }).toThrow('Missing selector annotation for MissingSelector'); + }).toThrowWith(message: 'Missing selector annotation for MissingSelector'); }); @@ -696,7 +697,7 @@ void main() { expect(() { c(es('
'), directives); - }).toThrow('Unknown selector format \'buttonbar button\' for InvalidSelector'); + }).toThrowWith(message: 'Unknown selector format \'buttonbar button\' for InvalidSelector'); }); }); diff --git a/test/core_dom/http_spec.dart b/test/core_dom/http_spec.dart index e31d75565..e541ed27b 100644 --- a/test/core_dom/http_spec.dart +++ b/test/core_dom/http_spec.dart @@ -91,7 +91,7 @@ void main() { http(url: '/url', method: 'POST'); expect(() { flush(); - }).toThrow('with different data'); + }).toThrowWith(message: 'with different data'); // satisfy the expectation for our afterEach's assert. http(url: '/url', method: 'POST', data: 'null'); diff --git a/test/core_dom/ng_animate_spec.dart b/test/core_dom/ng_animate_spec.dart index 3d85fd742..c1f433a5e 100644 --- a/test/core_dom/ng_animate_spec.dart +++ b/test/core_dom/ng_animate_spec.dart @@ -64,17 +64,17 @@ main() { expect(_.rootElement.text).toEqual("BbAa"); }); }); - + describe('NoOpAnimation', () { it('should not do anything async unless the future is asked for', () { var completer = new NoOpAnimation(); expect(completer).toBeDefined(); }); - + it('should create a future once onCompleted is accessed', () { - expect(() => new NoOpAnimation().onCompleted).toThrow(); + expect(() => new NoOpAnimation().onCompleted).toThrowWith(); }); - + it('should return a [COMPLETED_IGNORED] result when completed.', async(() { bool success = false; new NoOpAnimation().onCompleted.then((result) { diff --git a/test/directive/ng_model_spec.dart b/test/directive/ng_model_spec.dart index 20b87665b..50ec19a6a 100644 --- a/test/directive/ng_model_spec.dart +++ b/test/directive/ng_model_spec.dart @@ -1370,7 +1370,7 @@ void main() { inputElement.value = 'xzy'; _.triggerEvent(inputElement, 'change'); _.rootScope.apply(); - })).toThrow('love'); + })).toThrowWith(message: 'love'); }); }); diff --git a/test/directive/ng_repeat_spec.dart b/test/directive/ng_repeat_spec.dart index 3dde712a0..f2519b151 100644 --- a/test/directive/ng_repeat_spec.dart +++ b/test/directive/ng_repeat_spec.dart @@ -275,18 +275,18 @@ main() { it(r'should error on wrong parsing of ngRepeat', () { expect(() { compile('
')(); - }).toThrow("[NgErr7] ngRepeat error! Expected expression in form of " - "'_item_ in _collection_[ track by _id_]' but got " - "'i dont parse'."); + }).toThrowWith(message: "[NgErr7] ngRepeat error! Expected expression in form of " + "'_item_ in _collection_[ track by _id_]' but got " + "'i dont parse'."); }); it("should throw error when left-hand-side of ngRepeat can't be parsed", () { expect(() { compile('
')(); - }).toThrow("[NgErr8] ngRepeat error! '_item_' in '_item_ in " - "_collection_' should be an identifier or '(_key_, _value_)' " - "expression, but got 'i dont parse'."); + }).toThrowWith(message: "[NgErr8] ngRepeat error! '_item_' in '_item_ in " + "_collection_' should be an identifier or '(_key_, _value_)' " + "expression, but got 'i dont parse'."); }); diff --git a/test/directive/ng_src_boolean_spec.dart b/test/directive/ng_src_boolean_spec.dart index 8062ded57..f64ea4100 100644 --- a/test/directive/ng_src_boolean_spec.dart +++ b/test/directive/ng_src_boolean_spec.dart @@ -122,9 +122,10 @@ main() { xit('should NOT interpolate a multi-part expression for non-img src attribute', () { expect(() { _.compile('
'); - }).toThrow("Error while interpolating: some/{{id}}\nStrict " + - "Contextual Escaping disallows interpolations that concatenate multiple expressions " + - "when a trusted value is required. See http://docs.angularjs.org/api/ng.sce"); + }).toThrowWith(message: "Error while interpolating: some/{{id}}\nStrict Contextual Escaping " + "disallows interpolations that concatenate multiple expressions " + "when a trusted value is required. " + "See http://docs.angularjs.org/api/ng.sce"); }); @@ -146,8 +147,9 @@ main() { _.rootScope.context['id'] = sce.trustAsUrl('http://somewhere'); }); _.rootElement.attributes['src']; - }).toThrow("Can't interpolate: {{id}}\nError: [sce:insecurl] Viewed " + - "loading resource from url not allowed by sceDelegate policy. URL: http://somewhere"); + }).toThrowWith(message: "Can't interpolate: {{id}}\nError: [sce:insecurl] Viewed loading " + "resource from url not allowed by sceDelegate policy. " + "URL: http://somewhere"); }); }); diff --git a/test/mock/http_backend_spec.dart b/test/mock/http_backend_spec.dart index e8842f2b3..f1cc03c7a 100644 --- a/test/mock/http_backend_spec.dart +++ b/test/mock/http_backend_spec.dart @@ -80,7 +80,7 @@ void main() { hb.when('GET', '/url1').respond(200, 'content'); expect(() { hb('GET', '/xxx', noop); - }).toThrow('Unexpected request: GET /xxx\nNo more requests expected'); + }).toThrowWith(message: 'Unexpected request: GET /xxx\nNo more requests expected'); }); @@ -93,7 +93,7 @@ void main() { }); hb.flush(); microLeap(); - }).toThrow('exceptiona'); + }).toThrowWith(message: 'exceptiona'); })); @@ -231,7 +231,7 @@ void main() { expect(() { hb('GET', '/url2', noop, headers: {}); - }).toThrow('Unexpected request: GET /url2\nExpected GET /url1'); + }).toThrowWith(message: 'Unexpected request: GET /url2\nExpected GET /url1'); }); @@ -256,8 +256,8 @@ void main() { expect(() { hb('GET', '/match', noop, headers: {}); - }).toThrow('Expected GET /match with different headers\n' + - 'EXPECTED: {"Content-Type":"application/json"}\nGOT: {}'); + }).toThrowWith(message: 'Expected GET /match with different headers\n' + 'EXPECTED: {"Content-Type":"application/json"}\nGOT: {}'); }); @@ -267,8 +267,8 @@ void main() { expect(() { hb('GET', '/match', noop, data: 'different'); - }).toThrow('Expected GET /match with different data\n' + - 'EXPECTED: some-data\nGOT: different'); + }).toThrowWith(message: 'Expected GET /match with different data\n' + + 'EXPECTED: some-data\nGOT: different'); }); @@ -318,19 +318,19 @@ void main() { hb.when('GET').respond(200, ''); hb('GET', '/url', callback); - expect(() {hb.flush(2);}).toThrow('No more pending request to flush !'); + expect(() {hb.flush(2);}).toThrowWith(message: 'No more pending request to flush !'); expect(callback).toHaveBeenCalledOnce(); }); it('should throw exception when no request to flush', () { - expect(() {hb.flush();}).toThrow('No pending request to flush !'); + expect(() {hb.flush();}).toThrowWith(message: 'No pending request to flush !'); hb.when('GET').respond(200, ''); hb('GET', '/some', callback); hb.flush(); - expect(() {hb.flush();}).toThrow('No pending request to flush !'); + expect(() {hb.flush();}).toThrowWith(message: 'No pending request to flush !'); }); @@ -339,7 +339,7 @@ void main() { hb.expect('GET', '/url2').respond(); hb('GET', '/url1', noop); - expect(() {hb.flush();}).toThrow('Unsatisfied requests: GET /url2'); + expect(() {hb.flush();}).toThrowWith(message: 'Unsatisfied requests: GET /url2'); }); }); @@ -366,7 +366,7 @@ void main() { hb.when('GET', '/test'); expect(() { hb('GET', '/test', callback); - }).toThrow('No response defined !'); + }).toThrowWith(message: 'No response defined !'); }); @@ -374,7 +374,7 @@ void main() { hb.expect('GET', '/url'); expect(() { hb('GET', '/url', callback); - }).toThrow('No response defined !'); + }).toThrowWith(message: 'No response defined !'); }); @@ -397,7 +397,7 @@ void main() { hb('POST', '/u1', noop, data: 'ddd', headers: {}); expect(() {hb.verifyNoOutstandingExpectation();}). - toThrow('Unsatisfied requests: GET /u2, POST /u3'); + toThrowWith(message: 'Unsatisfied requests: GET /u2, POST /u3'); }); @@ -428,7 +428,7 @@ void main() { expect(() { hb.verifyNoOutstandingRequest(); - }).toThrow('Unflushed requests: 1'); + }).toThrowWith(message: 'Unflushed requests: 1'); }); }); diff --git a/test/mock/zone_spec.dart b/test/mock/zone_spec.dart index b1aaf9c83..2bfe4ce97 100644 --- a/test/mock/zone_spec.dart +++ b/test/mock/zone_spec.dart @@ -9,14 +9,14 @@ void main() { it('should throw an error on scheduleMicrotask', () { expect(sync(() { scheduleMicrotask(() => dump("i never run")); - })).toThrow('scheduleMicrotask called from sync function'); + })).toThrowWith(message: 'scheduleMicrotask called from sync function'); }); it('should throw an error on timer', () { expect(sync(() { Timer.run(() => dump("i never run")); - })).toThrow('Timer created from sync function'); + })).toThrowWith(message: 'Timer created from sync function'); }); @@ -24,7 +24,7 @@ void main() { expect(sync(() { new Timer.periodic(new Duration(milliseconds: 10), (_) => dump("i never run")); - })).toThrow('periodic Timer created from sync function'); + })).toThrowWith(message: 'periodic Timer created from sync function'); }); }); @@ -126,7 +126,7 @@ void main() { throw ["dangling"]; }); })(); - }).toThrow("dangling"); + }).toThrowWith(message: "dangling"); }); @@ -135,7 +135,7 @@ void main() { async(() { throw "blah"; })(); - }).toThrow("blah"); + }).toThrowWith(message: "blah"); }); @@ -143,14 +143,14 @@ void main() { expect(async(() { new Future.value('s').then((_) { throw "blah then"; }); microLeap(); - })).toThrow("blah then"); + })).toThrowWith(message: "blah then"); }); it('should throw errors from the microLeap call', async(() { new Future.value('s').then((_) { throw "blah then 2"; }); expect(() { microLeap(); - }).toThrow("blah then 2"); + }).toThrowWith(message: "blah then 2"); })); describe('timers', () { @@ -330,7 +330,7 @@ void main() { expect(async(() { new Timer.periodic(new Duration(milliseconds: 10), (_) => dump("i never run")); - })).toThrow('1 active timer(s) are still in the queue.'); + })).toThrowWith(message: '1 active timer(s) are still in the queue.'); }); }); });