Files
sdk/tests/dartdevc/container_test.dart
T
Mark Zhou bd30532d82 [dartdevc] Creating container entrypoints for expression eval.
The expression evaluator should now index/read object containers (types and symbols right now) via accessors like 'A$Eval'.

Fixes #44494

Change-Id: I31d203cfe59a6e2c03eeb22e8c86270c28b5e2fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176923
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2021-01-06 00:20:29 +00:00

39 lines
1.2 KiB
Dart

// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Tests that evaluation containers aren't renamed by DDC.
import 'dart:_foreign_helper' as helper show JS;
import 'package:expect/expect.dart';
class T {
final int T$Eval = 0;
final int S$Eval = 0;
String get realT$Eval => helper.JS<String>('', 'T\$Eval.toString()');
String get realS$Eval => helper.JS<String>('', 'S\$Eval.toString()');
}
class T$Eval {}
void main() {
var T$Eval = T();
var S$Eval = T$Eval;
var container1 = helper.JS<String>('', 'T\$Eval.toString()');
var container2 = helper.JS<String>('', 'S\$Eval.toString()');
// Evaluation containers are JS Objects. Ensure they aren't shadowed by JS
// symbols or Dart constructs.
Expect.equals('[object Object]', '$container1');
Expect.equals('[object Object]', '$container2');
Expect.equals("Instance of 'T'", T$Eval.toString());
Expect.equals(T$Eval.T$Eval, 0);
Expect.equals(T$Eval.S$Eval, 0);
Expect.notEquals(T$Eval.toString(), container1);
Expect.equals(T$Eval.realT$Eval, container1);
Expect.equals(T$Eval.realS$Eval, container2);
}