OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // |
| 5 // Dart test program for testing native float arrays. |
| 6 |
| 7 // VMOptions=--optimization_counter_threshold=10 --no-background_compilation |
| 8 |
| 9 // Library tag to be able to run in html test framework. |
| 10 library FloatArrayTest; |
| 11 |
| 12 import "package:expect/expect.dart"; |
| 13 import 'dart:typed_data'; |
| 14 |
| 15 void testIndexOf32() { |
| 16 var list = new Float32List(10); |
| 17 for (int i = 0; i < list.length; i++) { |
| 18 list[i] = i + 10.0; |
| 19 } |
| 20 /*@compile-error=unspecified*/ Expect.equals(0, list.indexOf(10)); |
| 21 /*@compile-error=unspecified*/ Expect.equals(5, list.indexOf(15)); |
| 22 /*@compile-error=unspecified*/ Expect.equals(9, list.indexOf(19)); |
| 23 /*@compile-error=unspecified*/ Expect.equals(-1, list.indexOf(20)); |
| 24 } |
| 25 |
| 26 void testBadValues32() { |
| 27 var list = new Float32List(10); |
| 28 list[0] = 2.0; |
| 29 /*@compile-error=unspecified*/ list[0] = 2; |
| 30 /*@compile-error=unspecified*/ list[0] = "hello"; |
| 31 } |
| 32 |
| 33 void testIndexOf64() { |
| 34 var list = new Float64List(10); |
| 35 for (int i = 0; i < list.length; i++) { |
| 36 list[i] = i + 10.0; |
| 37 } |
| 38 /*@compile-error=unspecified*/ Expect.equals(0, list.indexOf(10)); |
| 39 /*@compile-error=unspecified*/ Expect.equals(5, list.indexOf(15)); |
| 40 /*@compile-error=unspecified*/ Expect.equals(9, list.indexOf(19)); |
| 41 /*@compile-error=unspecified*/ Expect.equals(-1, list.indexOf(20)); |
| 42 } |
| 43 |
| 44 void testBadValues64() { |
| 45 var list = new Float64List(10); |
| 46 list[0] = 2.0; |
| 47 /*@compile-error=unspecified*/ list[0] = 2; |
| 48 /*@compile-error=unspecified*/ list[0] = "hello"; |
| 49 } |
| 50 |
| 51 main() { |
| 52 testIndexOf32(); |
| 53 testIndexOf64(); |
| 54 testBadValues32(); |
| 55 testBadValues64(); |
| 56 } |
OLD | NEW |