| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library dart2js.serialization_model_test; | 5 library dart2js.serialization_model_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'package:async_helper/async_helper.dart'; | 8 import 'package:async_helper/async_helper.dart'; |
| 9 import 'package:expect/expect.dart'; | 9 import 'package:expect/expect.dart'; |
| 10 import 'package:compiler/src/closure.dart'; | 10 import 'package:compiler/src/closure.dart'; |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 if (a is ClosureFieldElement && b is ClosureFieldElement) { | 245 if (a is ClosureFieldElement && b is ClosureFieldElement) { |
| 246 return areElementsEquivalent(a.closureClass, b.closureClass) && | 246 return areElementsEquivalent(a.closureClass, b.closureClass) && |
| 247 areLocalsEquivalent(a.local, b.local); | 247 areLocalsEquivalent(a.local, b.local); |
| 248 } else if (a is BoxFieldElement && b is BoxFieldElement) { | 248 } else if (a is BoxFieldElement && b is BoxFieldElement) { |
| 249 return areElementsEquivalent(a.variableElement, b.variableElement) && | 249 return areElementsEquivalent(a.variableElement, b.variableElement) && |
| 250 areLocalsEquivalent(a.box, b.box); | 250 areLocalsEquivalent(a.box, b.box); |
| 251 } | 251 } |
| 252 return false; | 252 return false; |
| 253 } | 253 } |
| 254 | 254 |
| 255 bool areClosureScopesEquivalent(ClosureScope a, ClosureScope b) { | 255 bool areCapturedScopesEquivalent(CapturedScope a, CapturedScope b) { |
| 256 if (a == b) return true; | 256 if (a == b) return true; |
| 257 if (a == null || b == null) return false; | 257 if (a == null || b == null) return false; |
| 258 if (!areLocalsEquivalent(a.context, b.context)) { | 258 if (!areLocalsEquivalent(a.context, b.context)) { |
| 259 return false; | 259 return false; |
| 260 } | 260 } |
| 261 if (!areLocalsEquivalent(a.thisLocal, b.thisLocal)) { | 261 if (!areLocalsEquivalent(a.thisLocal, b.thisLocal)) { |
| 262 return false; | 262 return false; |
| 263 } | 263 } |
| 264 var aBoxed = {}; | 264 var aBoxed = {}; |
| 265 a.forEachBoxedVariable((k, v) => aBoxed[k] = v); | 265 a.forEachBoxedVariable((k, v) => aBoxed[k] = v); |
| 266 var bBoxed = {}; | 266 var bBoxed = {}; |
| 267 b.forEachBoxedVariable((k, v) => bBoxed[k] = v); | 267 b.forEachBoxedVariable((k, v) => bBoxed[k] = v); |
| 268 checkMaps(aBoxed, bBoxed, 'ClosureScope.boxedVariables', areLocalsEquivalent, | 268 checkMaps(aBoxed, bBoxed, 'CapturedScope.boxedVariables', areLocalsEquivalent, |
| 269 areElementsEquivalent); | 269 areElementsEquivalent); |
| 270 return true; | 270 return true; |
| 271 } | 271 } |
| 272 | 272 |
| 273 String nodeToString(Node node) { | 273 String nodeToString(Node node) { |
| 274 String text = '$node'; | 274 String text = '$node'; |
| 275 if (text.length > 40) { | 275 if (text.length > 40) { |
| 276 return '(${node.runtimeType}) ${text.substring(0, 37)}...'; | 276 return '(${node.runtimeType}) ${text.substring(0, 37)}...'; |
| 277 } | 277 } |
| 278 return '(${node.runtimeType}) $text'; | 278 return '(${node.runtimeType}) $text'; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 293 check(outputUnit1, outputUnit2, 'OutputUnit.isMainOutput $message', | 293 check(outputUnit1, outputUnit2, 'OutputUnit.isMainOutput $message', |
| 294 outputUnit1.isMainOutput, outputUnit2.isMainOutput); | 294 outputUnit1.isMainOutput, outputUnit2.isMainOutput); |
| 295 checkSetEquivalence( | 295 checkSetEquivalence( |
| 296 outputUnit1, | 296 outputUnit1, |
| 297 outputUnit2, | 297 outputUnit2, |
| 298 'OutputUnit.imports $message', | 298 'OutputUnit.imports $message', |
| 299 outputUnit1.imports, | 299 outputUnit1.imports, |
| 300 outputUnit2.imports, | 300 outputUnit2.imports, |
| 301 (a, b) => areElementsEquivalent(a.declaration, b.declaration)); | 301 (a, b) => areElementsEquivalent(a.declaration, b.declaration)); |
| 302 } | 302 } |
| OLD | NEW |