OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Test that parameters keep their names in the output. | 4 // Test that parameters keep their names in the output. |
5 | 5 |
6 #import("compiler_helper.dart"); | 6 #import("compiler_helper.dart"); |
7 #import("parser_helper.dart"); | 7 #import("parser_helper.dart"); |
8 | 8 |
9 final String TEST_ONE = @""" | 9 const String TEST_ONE = @""" |
10 class A { foo() => 499; } | 10 class A { foo() => 499; } |
11 class B { bar() => 42; } | 11 class B { bar() => 42; } |
12 | 12 |
13 main() { | 13 main() { |
14 new A().foo(); | 14 new A().foo(); |
15 new B().bar(); | 15 new B().bar(); |
16 } | 16 } |
17 """; | 17 """; |
18 | 18 |
19 final String TEST_TWO = @""" | 19 const String TEST_TWO = @""" |
20 class A { | 20 class A { |
21 foo() => 499; | 21 foo() => 499; |
22 bar() => 42; | 22 bar() => 42; |
23 } | 23 } |
24 | 24 |
25 main() { | 25 main() { |
26 new A().foo(); | 26 new A().foo(); |
27 new A().bar(); | 27 new A().bar(); |
28 } | 28 } |
29 """; | 29 """; |
30 | 30 |
31 final String TEST_THREE = @""" | 31 const String TEST_THREE = @""" |
32 class A { | 32 class A { |
33 foo() => 499; | 33 foo() => 499; |
34 bar() => 42; | 34 bar() => 42; |
35 } | 35 } |
36 | 36 |
37 class B extends A { | 37 class B extends A { |
38 foo() => -499; | 38 foo() => -499; |
39 bar() => -42; | 39 bar() => -42; |
40 } | 40 } |
41 | 41 |
(...skipping 23 matching lines...) Expand all Loading... |
65 main() { | 65 main() { |
66 var a = new A(); | 66 var a = new A(); |
67 var b = new B(); | 67 var b = new B(); |
68 var x = a; | 68 var x = a; |
69 if (makeStaticInliningHard()) x = b; | 69 if (makeStaticInliningHard()) x = b; |
70 x.foo(); | 70 x.foo(); |
71 x.bar(); | 71 x.bar(); |
72 } | 72 } |
73 """; | 73 """; |
74 | 74 |
75 final String TEST_FOUR = @""" | 75 const String TEST_FOUR = @""" |
76 class A { foo() => 499; } | 76 class A { foo() => 499; } |
77 | 77 |
78 foo(f) { f(); } | 78 foo(f) { f(); } |
79 | 79 |
80 main() { | 80 main() { |
81 foo(new A().foo); | 81 foo(new A().foo); |
82 } | 82 } |
83 """; | 83 """; |
84 | 84 |
85 main() { | 85 main() { |
86 // At some point Dart2js generated bad object literals with dangling commas: | 86 // At some point Dart2js generated bad object literals with dangling commas: |
87 // { a: true, }. Make sure this doesn't happen again. | 87 // { a: true, }. Make sure this doesn't happen again. |
88 RegExp danglingComma = const RegExp(@',[ \n]*}'); | 88 RegExp danglingComma = const RegExp(@',[ \n]*}'); |
89 String generated = compileAll(TEST_ONE); | 89 String generated = compileAll(TEST_ONE); |
90 Expect.isFalse(danglingComma.hasMatch(generated)); | 90 Expect.isFalse(danglingComma.hasMatch(generated)); |
91 | 91 |
92 generated = compileAll(TEST_TWO); | 92 generated = compileAll(TEST_TWO); |
93 Expect.isFalse(danglingComma.hasMatch(generated)); | 93 Expect.isFalse(danglingComma.hasMatch(generated)); |
94 | 94 |
95 generated = compileAll(TEST_THREE); | 95 generated = compileAll(TEST_THREE); |
96 Expect.isFalse(danglingComma.hasMatch(generated)); | 96 Expect.isFalse(danglingComma.hasMatch(generated)); |
97 | 97 |
98 generated = compileAll(TEST_FOUR); | 98 generated = compileAll(TEST_FOUR); |
99 Expect.isFalse(danglingComma.hasMatch(generated)); | 99 Expect.isFalse(danglingComma.hasMatch(generated)); |
100 } | 100 } |
OLD | NEW |