| 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 | 4 |
| 5 package com.google.dart.compiler.ast; | 5 package com.google.dart.compiler.ast; |
| 6 | 6 |
| 7 import com.google.common.base.Joiner; | 7 import com.google.common.base.Joiner; |
| 8 import com.google.dart.compiler.CompilerTestCase; | 8 import com.google.dart.compiler.CompilerTestCase; |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 "// unit testcode", | 93 "// unit testcode", |
| 94 "var m = {\"a\" : 1, \"b\" : 2, \"c\" : 3};", | 94 "var m = {\"a\" : 1, \"b\" : 2, \"c\" : 3};", |
| 95 "")); | 95 "")); |
| 96 same(Joiner.on("\n").join( | 96 same(Joiner.on("\n").join( |
| 97 "// unit testcode", | 97 "// unit testcode", |
| 98 "var m = <int>{\"a\" : 1, \"b\" : 2, \"c\" : 3};", | 98 "var m = <int>{\"a\" : 1, \"b\" : 2, \"c\" : 3};", |
| 99 "")); | 99 "")); |
| 100 } | 100 } |
| 101 | 101 |
| 102 private void same(String sourceCode) { | 102 private void same(String sourceCode) { |
| 103 DartUnit unit = parseUnit("testcode", sourceCode); | 103 // Some of the syntax we are testing is only valid in a system library |
| 104 DartUnit unit = parseUnitAsSystemLibrary("testcode", sourceCode); |
| 104 String result = unit.toSource(); | 105 String result = unit.toSource(); |
| 105 assertEquals(sourceCode, result); | 106 assertEquals(sourceCode, result); |
| 106 } | 107 } |
| 107 | 108 |
| 108 private void testClassMemeber(String stmt) { | 109 private void testClassMemeber(String stmt) { |
| 109 String boilerplated = | 110 String boilerplated = |
| 110 "// unit testcode\n" + | 111 "// unit testcode\n" + |
| 111 "class c {\n" + | 112 "class c {\n" + |
| 112 "\n" + | 113 "\n" + |
| 113 ""+stmt+"" + | 114 ""+stmt+"" + |
| 114 "}\n" + | 115 "}\n" + |
| 115 "\n"; | 116 "\n"; |
| 116 same(boilerplated); | 117 same(boilerplated); |
| 117 } | 118 } |
| 118 | 119 |
| 119 private void testStmt(String stmt) { | 120 private void testStmt(String stmt) { |
| 120 String boilerplated = | 121 String boilerplated = |
| 121 " m() {\n" + | 122 " m() {\n" + |
| 122 " "+stmt+";\n" + | 123 " "+stmt+";\n" + |
| 123 " }\n"; | 124 " }\n"; |
| 124 testClassMemeber(boilerplated); | 125 testClassMemeber(boilerplated); |
| 125 } | 126 } |
| 126 } | 127 } |
| OLD | NEW |