Index: packages/code_transformers/test/messages_test.dart |
diff --git a/packages/code_transformers/test/messages_test.dart b/packages/code_transformers/test/messages_test.dart |
index 49142c64c9e1aec1b55c2a390d2d9078f91e37e1..526263d766034d125f679f3214279e0407f225a9 100644 |
--- a/packages/code_transformers/test/messages_test.dart |
+++ b/packages/code_transformers/test/messages_test.dart |
@@ -3,30 +3,39 @@ |
// BSD-style license that can be found in the LICENSE file. |
/// Tests for some of the utility helper functions used by the compiler. |
+@TestOn('vm') |
library polymer.test.build.messages_test; |
import 'dart:convert'; |
-import 'package:unittest/unittest.dart'; |
+import 'package:test/test.dart'; |
import 'package:code_transformers/messages/messages.dart'; |
import 'package:source_span/source_span.dart'; |
main() { |
group('snippet', () { |
test('template with no-args works', () { |
- expect(new MessageTemplate(_id('code_transformers', 1), |
- 'this message has no args', '', '').snippet, |
+ expect( |
+ new MessageTemplate(_id('code_transformers', 1), |
+ 'this message has no args', '', '') |
+ .snippet, |
'this message has no args'); |
}); |
test('template with args throws', () { |
- expect(() => new MessageTemplate(_id('code_transformers', 1), |
- 'this message has %-args-%', '', '').snippet, throws); |
+ expect( |
+ () => new MessageTemplate(_id('code_transformers', 1), |
+ 'this message has %-args-%', '', '') |
+ .snippet, |
+ throwsA(contains("missing argument args"))); |
}); |
test('can pass arguments to create snippet', () { |
- expect(new MessageTemplate(_id('code_transformers', 1), |
- 'a %-b-% c something %-name-% too', '', '') |
- .create({'b': "1", 'name': 'foo'}).snippet, |
+ expect( |
+ new MessageTemplate( |
+ _id('code_transformers', 1), |
+ 'a %-b-% c something %-name-% too', |
+ '', |
+ '').create({'b': "1", 'name': 'foo'}).snippet, |
'a 1 c something foo too'); |
}); |
}); |
@@ -45,6 +54,7 @@ main() { |
_eq(msg) { |
expect(new MessageId.fromJson(toJson(msg)) == msg, isTrue); |
} |
+ |
_eq(const MessageId('hi', 23)); |
_eq(new MessageId('hi', 23)); |
_eq(new MessageId('a_b', 23)); |
@@ -59,6 +69,7 @@ main() { |
expect(msg.id, parsed.id); |
expect(msg.snippet, parsed.snippet); |
} |
+ |
_eq(new Message(_id('hi', 33), 'snippet here')); |
_eq(new MessageTemplate( |
_id('hi', 33), 'snippet', 'ignored', 'ignored')); |
@@ -72,6 +83,7 @@ main() { |
expect(entry.level, parsed.level); |
expect(entry.span, parsed.span); |
} |
+ |
_eq(_entry(33, 'hi there', 12)); |
_eq(_entry(33, 'hi there-', 11)); |
}); |
@@ -85,7 +97,8 @@ main() { |
expect(table.entries[_id('hi', 11)].length, 2); |
expect(table.entries[_id('hi', 13)].length, 1); |
- var table2 = new LogEntryTable.fromJson(toJson(table)); |
+ var table2 = |
+ new LogEntryTable.fromJson(toJson(table) as Map<String, Iterable>); |
expect(table2.entries.length, 2); |
expect(table2.entries[_id('hi', 11)].length, 2); |
expect(table2.entries[_id('hi', 13)].length, 1); |
@@ -99,9 +112,12 @@ main() { |
}); |
} |
} |
+ |
_id(s, i) => new MessageId(s, i); |
_entry(id, snippet, offset) => new BuildLogEntry( |
- new Message(_id('hi', id), snippet), new SourceSpan( |
+ new Message(_id('hi', id), snippet), |
+ new SourceSpan( |
new SourceLocation(offset, sourceUrl: 'a', line: 1, column: 3), |
new SourceLocation(offset + 2, sourceUrl: 'a', line: 1, column: 5), |
- 'hi'), 'Warning'); |
+ 'hi'), |
+ 'Warning'); |