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 // |
| 5 // OtherResources=readline_test1.dat |
4 | 6 |
5 // Regression test for missing immutability check in the ListSet | 7 // Regression test for missing immutability check in the ListSet |
6 // methods in the API. This allowed overwriting const Lists. | 8 // methods in the API. This allowed overwriting const Lists. |
7 | 9 |
8 import "package:expect/expect.dart"; | 10 import "package:expect/expect.dart"; |
9 import "dart:io"; | 11 import "dart:io"; |
10 | 12 |
11 String getFilename(String path) { | 13 String getFilename(String path) { |
12 var testPath = Platform.script.resolve('../../../$path'); | 14 return Platform.script.resolve(path).toFilePath(); |
13 return new File.fromUri(testPath).existsSync() | |
14 ? testPath.toFilePath() | |
15 : Platform.script.resolve('../../../runtime/$path').toFilePath(); | |
16 } | 15 } |
17 | 16 |
18 | |
19 void main() { | 17 void main() { |
20 var a = const [0]; | 18 var a = const [0]; |
21 var b = const [0]; | 19 var b = const [0]; |
22 Expect.identical(a, b); | 20 Expect.identical(a, b); |
23 | 21 |
24 String filename = getFilename("bin/file_test.cc"); | 22 String filename = getFilename("readline_test1.dat"); |
25 File file = new File(filename); | 23 File file = new File(filename); |
26 file.open().then((input) { | 24 file.open().then((input) { |
27 try { | 25 try { |
28 input.readIntoSync(a, 0, 1); | 26 input.readIntoSync(a, 0, 1); |
29 Expect.fail("no exception thrown"); | 27 Expect.fail("no exception thrown"); |
30 } catch (e) { | 28 } catch (e) { |
31 Expect.isTrue(e is UnsupportedError); | 29 Expect.isTrue(e is UnsupportedError); |
32 } | 30 } |
33 Expect.equals(0, a[0]); | 31 Expect.equals(0, a[0]); |
34 Expect.equals(0, b[0]); | 32 Expect.equals(0, b[0]); |
35 input.closeSync(); | 33 input.closeSync(); |
36 }); | 34 }); |
37 } | 35 } |
OLD | NEW |