mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:29:48 +00:00
0429dda6d2
Change-Id: I7567d8f705b84a286e4091ece850ccbf5966e6b7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149490 Commit-Queue: Bob Nystrom <rnystrom@google.com> Commit-Queue: Srujan Gaddam <srujzs@google.com> Auto-Submit: Bob Nystrom <rnystrom@google.com> Reviewed-by: Srujan Gaddam <srujzs@google.com>
28 lines
930 B
Dart
28 lines
930 B
Dart
// Copyright (c) 2011, 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.
|
|
// VMOptions=--enable_type_checks
|
|
//
|
|
// Dart test program testing type checks in map literals.
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
class MapLiteral4Test<T> {
|
|
test() {
|
|
int result = 0;
|
|
var m = <String, String>{"a": 0}; //# 01: compile-time error
|
|
var m = <String, int>{"a": 0}; //# 02: ok
|
|
m[2] = 1; //# 02: compile-time error
|
|
var m = <String, T>{"a": "b"}; //# 03: compile-time error
|
|
var m = <String, T>{"a": 0}; //# 04: compile-time error
|
|
var m = <String, T>{"a": 0}; //# 05: continued
|
|
m[2] = 1; //# 05: compile-time error
|
|
var m = const <String, int>{"a": 0}; //# 06: continued
|
|
m[2] = 1; //# 06: compile-time error
|
|
}
|
|
}
|
|
|
|
main() {
|
|
var t = new MapLiteral4Test<int>();
|
|
}
|