mirror of
https://github.com/dart-lang/sdk
synced 2024-09-20 07:31:33 +00:00
07b9df22ac
No behavioral changes, just getting rid of a lot of redundant closures and helper functions. Change-Id: I55c52c2cc9e5505bb64203c31aad8d76847f8eeb Reviewed-on: https://dart-review.googlesource.com/14320 Commit-Queue: Bob Nystrom <rnystrom@google.com> Reviewed-by: William Hesse <whesse@google.com>
45 lines
1.1 KiB
Dart
45 lines
1.1 KiB
Dart
// 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() {
|
|
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
|
|
Expect.throwsNoSuchMethodError(() => #a.toString()); //# 01: compile-time error
|
|
}
|