Files
sdk/tests/language/symbol/literal_runtime_test.dart
T
Robert Nystrom f638fe385b Migrate language_2/symbol to NNBD.
Change-Id: I05faaa3481bde1085af2b0e887e33310fc0592f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151472
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2020-06-17 02:19:16 +00:00

52 lines
1.2 KiB
Dart

// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.
// Copyright (c) 2013, 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.
// Test symbol literals.
library symbol_literal_test;
import 'package:expect/expect.dart';
foo(a, b) => Expect.isTrue(identical(a, b));
var check = foo; // Indirection used to avoid inlining.
testSwitch(Symbol s) {
switch (s) {
case #abc:
return 1;
case const Symbol("def"):
return 2;
default:
return 0;
}
}
main() {
bool doChecks = false;
if (doChecks) {
check(const Symbol("a"), #a);
check(const Symbol("a"), #a);
check(const Symbol("ab"), #ab);
check(const Symbol("ab"), #ab);
check(const Symbol("a.b"), #a.b);
check(const Symbol("a.b"), #a.b);
check(const Symbol("=="), #==);
check(const Symbol("=="), #==);
check(const Symbol("a.toString"), #a.toString);
}
Expect.equals(1, testSwitch(#abc));
const m = const <Symbol, int>{#A: 0, #B: 1};
Expect.equals(1, m[#B]);
// Tries to call the symbol literal #a.toString
}