Chromium Code Reviews| 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 final String TEST_ONE = @""" |
| 10 class A { } | 10 class A { } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 A(x) : this.x = x {} | 57 A(x) : this.x = x {} |
| 58 } | 58 } |
| 59 | 59 |
| 60 main() { | 60 main() { |
| 61 new A(3); | 61 new A(3); |
| 62 } | 62 } |
| 63 """; | 63 """; |
| 64 | 64 |
| 65 twoClasses() { | 65 twoClasses() { |
| 66 String generated = compileAll(TEST_ONE); | 66 String generated = compileAll(TEST_ONE); |
| 67 Expect.isTrue(generated.contains( | 67 Expect.isTrue(generated.contains("\$.A = function A() {\n};")); |
|
Lasse Reichstein Nielsen
2012/04/13 08:38:32
You can use a raw string to avoid the escaped $ (l
floitsch
2012/04/13 08:59:59
I would prefer keeping a string and not a regexp h
| |
| 68 "Isolate.prototype.A = function A() {\n};")); | 68 Expect.isTrue(generated.contains("\$.B = function B() {\n};")); |
| 69 Expect.isTrue(generated.contains( | |
| 70 "Isolate.prototype.B = function B() {\n};")); | |
| 71 } | 69 } |
| 72 | 70 |
| 73 subClass() { | 71 subClass() { |
| 74 checkOutput(String generated) { | 72 checkOutput(String generated) { |
| 75 Expect.isTrue( | 73 Expect.isTrue(generated.contains("\$.A = function A() {\n};")); |
| 76 generated.contains("Isolate.prototype.A = function A() {\n};")); | 74 Expect.isTrue(generated.contains("\$.B = function B() {\n};")); |
| 77 Expect.isTrue( | |
| 78 generated.contains("Isolate.prototype.B = function B() {\n};")); | |
| 79 Expect.isTrue(generated.contains(@"Isolate.$inherits = function")); | 75 Expect.isTrue(generated.contains(@"Isolate.$inherits = function")); |
| 80 Expect.isTrue(generated.contains( | 76 Expect.isTrue(generated.contains(@"Isolate.$inherits($.B, $.A);")); |
| 81 "Isolate.\$inherits(Isolate.prototype.B, Isolate.prototype.A);\n")); | |
| 82 } | 77 } |
| 83 | 78 |
| 84 checkOutput(compileAll(TEST_TWO)); | 79 checkOutput(compileAll(TEST_TWO)); |
| 85 checkOutput(compileAll(TEST_THREE)); | 80 checkOutput(compileAll(TEST_THREE)); |
| 86 } | 81 } |
| 87 | 82 |
| 88 fieldTest() { | 83 fieldTest() { |
| 89 String generated = compileAll(TEST_FOUR); | 84 String generated = compileAll(TEST_FOUR); |
| 90 Expect.isTrue(generated.contains(""" | 85 Expect.isTrue(generated.contains(@""" |
| 91 Isolate.prototype.B = function B(B_z, B_y, A_x) { | 86 $.B = function B(B_z, B_y, A_x) { |
| 92 this.z = B_z; | 87 this.z = B_z; |
| 93 this.y = B_y; | 88 this.y = B_y; |
| 94 this.x = A_x; | 89 this.x = A_x; |
| 95 };""")); | 90 };""")); |
| 96 } | 91 } |
| 97 | 92 |
| 98 constructor1() { | 93 constructor1() { |
| 99 String generated = compileAll(TEST_FIVE); | 94 String generated = compileAll(TEST_FIVE); |
| 100 Expect.isTrue(generated.contains("new \$.A(x);")); | 95 Expect.isTrue(generated.contains(@"new $.A(x);")); |
| 101 } | 96 } |
| 102 | 97 |
| 103 main() { | 98 main() { |
| 104 twoClasses(); | 99 twoClasses(); |
| 105 subClass(); | 100 subClass(); |
| 106 fieldTest(); | 101 fieldTest(); |
| 107 constructor1(); | 102 constructor1(); |
| 108 } | 103 } |
| OLD | NEW |