OLD | NEW |
---|---|
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'package:test/test.dart'; | 5 import 'package:test/test.dart'; |
6 import 'package:test/src/backend/platform_selector/ast.dart'; | 6 import 'package:test/src/backend/platform_selector/ast.dart'; |
7 import 'package:test/src/backend/platform_selector/parser.dart'; | 7 import 'package:test/src/backend/platform_selector/parser.dart'; |
8 | 8 |
9 /// A matcher that asserts that a value is a [ConditionalNode]. | 9 /// A matcher that asserts that a value is a [ConditionalNode]. |
10 Matcher _isConditionalNode = | 10 Matcher _isConditionalNode = |
11 new isInstanceOf<ConditionalNode>("ConditionalNode"); | 11 new isInstanceOf<ConditionalNode>(); |
kevmoo
2015/05/06 05:18:33
could be one line?
nweiz
2015/05/06 18:12:21
Done.
| |
12 | 12 |
13 /// A matcher that asserts that a value is an [OrNode]. | 13 /// A matcher that asserts that a value is an [OrNode]. |
14 Matcher _isOrNode = new isInstanceOf<OrNode>("OrNode"); | 14 Matcher _isOrNode = new isInstanceOf<OrNode>(); |
15 | 15 |
16 /// A matcher that asserts that a value is an [AndNode]. | 16 /// A matcher that asserts that a value is an [AndNode]. |
17 Matcher _isAndNode = new isInstanceOf<AndNode>("AndNode"); | 17 Matcher _isAndNode = new isInstanceOf<AndNode>(); |
18 | 18 |
19 /// A matcher that asserts that a value is a [NotNode]. | 19 /// A matcher that asserts that a value is a [NotNode]. |
20 Matcher _isNotNode = new isInstanceOf<NotNode>("NotNode"); | 20 Matcher _isNotNode = new isInstanceOf<NotNode>(); |
21 | 21 |
22 void main() { | 22 void main() { |
23 group("parses a conditional expression", () { | 23 group("parses a conditional expression", () { |
24 test("with identifiers", () { | 24 test("with identifiers", () { |
25 var node = _parse(" a ? b : c "); | 25 var node = _parse(" a ? b : c "); |
26 expect(node.toString(), equals("a ? b : c")); | 26 expect(node.toString(), equals("a ? b : c")); |
27 | 27 |
28 expect(node.span.text, equals("a ? b : c")); | 28 expect(node.span.text, equals("a ? b : c")); |
29 expect(node.span.start.offset, equals(2)); | 29 expect(node.span.start.offset, equals(2)); |
30 expect(node.span.end.offset, equals(11)); | 30 expect(node.span.end.offset, equals(11)); |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
258 (value) => value is VariableNode && value.name == name, | 258 (value) => value is VariableNode && value.name == name, |
259 'is a variable named "$name"'); | 259 'is a variable named "$name"'); |
260 | 260 |
261 void _expectToString(String selector, [String result]) { | 261 void _expectToString(String selector, [String result]) { |
262 if (result == null) result = selector; | 262 if (result == null) result = selector; |
263 expect(_toString(selector), equals(result), | 263 expect(_toString(selector), equals(result), |
264 reason: 'Expected toString of "$selector" to be "$result".'); | 264 reason: 'Expected toString of "$selector" to be "$result".'); |
265 } | 265 } |
266 | 266 |
267 String _toString(String selector) => new Parser(selector).parse().toString(); | 267 String _toString(String selector) => new Parser(selector).parse().toString(); |
OLD | NEW |