| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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:expect/expect.dart'; | 5 import 'package:expect/expect.dart'; |
| 6 import 'mock_compiler.dart'; | 6 import 'mock_compiler.dart'; |
| 7 import '../../../sdk/lib/_internal/compiler/implementation/js/js.dart' as jsAst; | 7 import '../../../sdk/lib/_internal/compiler/implementation/js/js.dart' as jsAst; |
| 8 import '../../../sdk/lib/_internal/compiler/implementation/js/js.dart' show js; | 8 import '../../../sdk/lib/_internal/compiler/implementation/js/js.dart' show js; |
| 9 | 9 |
| 10 void testExpression(String expression, [String expect = ""]) { | 10 void testExpression(String expression, [String expect = ""]) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 testError('a <=> b', 'Unknown operator'); | 89 testError('a <=> b', 'Unknown operator'); |
| 90 // Typeof. | 90 // Typeof. |
| 91 testExpression('typeof foo == "number"'); | 91 testExpression('typeof foo == "number"'); |
| 92 // Strange relation. | 92 // Strange relation. |
| 93 testExpression('a < b < c'); | 93 testExpression('a < b < c'); |
| 94 // Chained var. | 94 // Chained var. |
| 95 testExpression('var x = 0, y = 1.2, z = 42'); | 95 testExpression('var x = 0, y = 1.2, z = 42'); |
| 96 // Empty object literal. | 96 // Empty object literal. |
| 97 testExpression('foo({}, {})'); | 97 testExpression('foo({}, {})'); |
| 98 // *Can't handle non-empty object literals | 98 // *Can't handle non-empty object literals |
| 99 testError('foo({meaning: 42})', 'Expected RBRACE'); | 99 testExpression('foo({meaning: 42})'); |
| 100 // Literals. | 100 // Literals. |
| 101 testExpression('x(false, true, null)'); | 101 testExpression('x(false, true, null)'); |
| 102 // *We should really throw here. | 102 // *We should really throw here. |
| 103 testExpression('var false = 42'); | 103 testExpression('var false = 42'); |
| 104 testExpression('var new = 42'); | 104 testExpression('var new = 42'); |
| 105 // Bad keyword. | 105 // Bad keyword. |
| 106 testError('var typeof = 42', "Expected ALPHA"); | 106 testError('var typeof = 42', "Expected ALPHA"); |
| 107 // Malformed decimal/hex. | 107 // Malformed decimal/hex. |
| 108 testError('var x = 1.1.1', "Unparseable number"); | 108 testError('var x = 1.1.1', "Unparseable number"); |
| 109 testError('var x = 0xabcdefga', "Unparseable number"); | 109 testError('var x = 0xabcdefga', "Unparseable number"); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 testExpression("y = a == null ? b : a"); | 180 testExpression("y = a == null ? b : a"); |
| 181 testExpression("y = a == null ? b + c : a + c"); | 181 testExpression("y = a == null ? b + c : a + c"); |
| 182 testExpression("foo = a ? b : c ? d : e"); | 182 testExpression("foo = a ? b : c ? d : e"); |
| 183 testExpression("foo = a ? b ? c : d : e"); | 183 testExpression("foo = a ? b ? c : d : e"); |
| 184 testExpression("foo = (a = v) ? b = w : c = x ? d = y : e = z"); | 184 testExpression("foo = (a = v) ? b = w : c = x ? d = y : e = z"); |
| 185 testExpression("foo = (a = v) ? b = w ? c = x : d = y : e = z"); | 185 testExpression("foo = (a = v) ? b = w ? c = x : d = y : e = z"); |
| 186 // Stacked assignment. | 186 // Stacked assignment. |
| 187 testExpression("a = b = c"); | 187 testExpression("a = b = c"); |
| 188 testExpression("var a = b = c"); | 188 testExpression("var a = b = c"); |
| 189 } | 189 } |
| OLD | NEW |