Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1654)

Unified Diff: dart/pkg/polymer_expressions/test/parser_test.dart

Issue 336013003: Version 1.5.0-dev.4.14 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dart/pkg/polymer_expressions/test/globals_test.dart ('k') | dart/pkg/smoke/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/pkg/polymer_expressions/test/parser_test.dart
===================================================================
--- dart/pkg/polymer_expressions/test/parser_test.dart (revision 37358)
+++ dart/pkg/polymer_expressions/test/parser_test.dart (working copy)
@@ -11,6 +11,9 @@
expectParse(String s, Expression e) =>
expect(new Parser(s).parse(), e, reason: s);
+final Matcher throwsParseException =
+ throwsA(new isInstanceOf<ParseException>('ParseException'));
+
main() {
group('parser', () {
@@ -54,7 +57,7 @@
test('should parse binary operators', () {
var operators = ['+', '-', '*', '/', '%', '^', '==', '!=', '>', '<',
- '>=', '<=', '||', '&&', '&'];
+ '>=', '<=', '||', '&&', '&', '===', '!==', '|'];
for (var op in operators) {
expectParse('a $op b', binary(ident('a'), op, ident('b')));
expectParse('1 $op 2', binary(literal(1), op, literal(2)));
@@ -62,6 +65,12 @@
}
});
+ test('should thrown on unknown operators', () {
+ expect(() => parse('a ?? b'), throwsParseException);
+ expect(() => parse('a &&& b'), throwsParseException);
+ expect(() => parse('a ==== b'), throwsParseException);
+ });
+
test('should give multiply higher associativity than plus', () {
expectParse('a + b * c',
binary(ident('a'), '+', binary(ident('b'), '*', ident('c'))));
@@ -155,7 +164,7 @@
expectParse('a ? b : c', ternary(ident('a'), ident('b'), ident('c')));
expectParse('a.a ? b.a : c.a', ternary(getter(ident('a'), 'a'),
getter(ident('b'), 'a'), getter(ident('c'), 'a')));
- expect(() => parse('a + 1 ? b + 1 :: c.d + 3'), throws);
+ expect(() => parse('a + 1 ? b + 1 :: c.d + 3'), throwsParseException);
});
test('ternary operators have lowest associativity', () {
@@ -189,7 +198,7 @@
});
test('should reject comprehension with non-assignable left expression', () {
- expect(() => parse('a + 1 in b'), throwsException);
+ expect(() => parse('a + 1 in b'), throwsParseException);
});
test('should parse "as" expressions', () {
@@ -197,10 +206,9 @@
});
skip_test('should reject keywords as identifiers', () {
- expect(() => parse('a.in'), throws);
- expect(() => parse('a.as'), throws);
- // TODO: re-enable when 'this' is a keyword
-// expect(() => parse('a.this'), throws);
+ expect(() => parse('a.in'), throwsParseException);
+ expect(() => parse('a.as'), throwsParseException);
+ expect(() => parse('a.this'), throwsParseException);
});
test('should parse map literals', () {
« no previous file with comments | « dart/pkg/polymer_expressions/test/globals_test.dart ('k') | dart/pkg/smoke/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698