OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Regression test for missing immutability check in the ListSet | 5 // Regression test for missing immutability check in the ListSet |
6 // methods in the API. This allowed overwriting const Lists. | 6 // methods in the API. This allowed overwriting const Lists. |
7 | 7 |
8 import "package:expect/expect.dart"; | |
9 import "dart:io"; | 8 import "dart:io"; |
10 | 9 |
11 String getFilename(String path) => | 10 String getFilename(String path) => |
12 new File(path).existsSync() ? path : 'runtime/$path'; | 11 new File(path).existsSync() ? path : 'runtime/$path'; |
13 | 12 |
14 void main() { | 13 void main() { |
15 var a = const [0]; | 14 var a = const [0]; |
16 var b = const [0]; | 15 var b = const [0]; |
17 Expect.identical(a, b); | 16 Expect.identical(a, b); |
18 | 17 |
19 String filename = getFilename("bin/file_test.cc"); | 18 String filename = getFilename("bin/file_test.cc"); |
20 File file = new File(filename); | 19 File file = new File(filename); |
21 file.open().then((input) { | 20 file.open().then((input) { |
22 try { | 21 try { |
23 input.readListSync(a, 0, 1); | 22 input.readListSync(a, 0, 1); |
24 Expect.fail("no exception thrown"); | 23 Expect.fail("no exception thrown"); |
25 } catch (e) { | 24 } catch (e) { |
26 Expect.isTrue(e is UnsupportedError); | 25 Expect.isTrue(e is UnsupportedError); |
27 } | 26 } |
28 Expect.equals(0, a[0]); | 27 Expect.equals(0, a[0]); |
29 Expect.equals(0, b[0]); | 28 Expect.equals(0, b[0]); |
30 }); | 29 }); |
31 } | 30 } |
OLD | NEW |