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 // VMOptions=--optimization_counter_threshold=10 --no-use-osr | 5 // VMOptions=--optimization_counter_threshold=10 --no-use-osr |
6 | 6 |
7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
8 | 8 |
9 test1(a, start, step, N) { | 9 test1(a, start, step, N) { |
10 var e; | 10 var e; |
(...skipping 15 matching lines...) Expand all Loading... |
26 var e; | 26 var e; |
27 for (var i = 0, j = 1, k = 0; i < a.length - 1; i++, j++, k++) { | 27 for (var i = 0, j = 1, k = 0; i < a.length - 1; i++, j++, k++) { |
28 e = b[k] = a[j - 1]; | 28 e = b[k] = a[j - 1]; |
29 } | 29 } |
30 return e; | 30 return e; |
31 } | 31 } |
32 | 32 |
33 test4(a, b) { | 33 test4(a, b) { |
34 var e; | 34 var e; |
35 if (a.length < 2) { | 35 if (a.length < 2) { |
36 return; | 36 return null; |
37 } | 37 } |
38 | 38 |
39 for (var i = 0, j = 1, k = 0; i < a.length - 1; i++, j++, k++) { | 39 for (var i = 0, j = 1, k = 0; i < a.length - 1; i++, j++, k++) { |
40 e = b[k] = a[j - 1]; | 40 e = b[k] = a[j - 1]; |
41 } | 41 } |
42 return e; | 42 return e; |
43 } | 43 } |
44 | 44 |
45 test5(a, b, k0) { | 45 test5(a, b, k0) { |
46 var e; | 46 var e; |
47 if (a.length < 2) { | 47 if (a.length < 2) { |
48 return; | 48 return null; |
49 } | 49 } |
50 | 50 |
51 if (k0 > 1) { | 51 if (k0 > 1) { |
52 return; | 52 return null; |
53 } | 53 } |
54 | 54 |
55 for (var i = 0, j = 1, k = 0; i < a.length - 1; i++, j++, k++) { | 55 for (var i = 0, j = 1, k = 0; i < a.length - 1; i++, j++, k++) { |
56 e = b[k - k0] = a[j - 1]; | 56 e = b[k - k0] = a[j - 1]; |
57 } | 57 } |
58 return e; | 58 return e; |
59 } | 59 } |
60 | 60 |
61 test6(a, M, N) { | 61 test6(a, M, N) { |
62 var e = 0; | 62 var e = 0; |
(...skipping 15 matching lines...) Expand all Loading... |
78 Expect.equals(a[a.length - 2], test4(a, b)); | 78 Expect.equals(a[a.length - 2], test4(a, b)); |
79 Expect.equals(a[a.length - 2], test5(a, b, 0)); | 79 Expect.equals(a[a.length - 2], test5(a, b, 0)); |
80 Expect.equals(6 , test6(a, 2, 2)); | 80 Expect.equals(6 , test6(a, 2, 2)); |
81 } | 81 } |
82 | 82 |
83 test1(a, 0, 2, a.length ~/ 2); | 83 test1(a, 0, 2, a.length ~/ 2); |
84 Expect.throws(() => test1(a, 1, 1, a.length)); | 84 Expect.throws(() => test1(a, 1, 1, a.length)); |
85 Expect.throws(() => test2(a, new List(a.length - 1))); | 85 Expect.throws(() => test2(a, new List(a.length - 1))); |
86 Expect.throws(() => test6(a, 4, 3)); | 86 Expect.throws(() => test6(a, 4, 3)); |
87 } | 87 } |
OLD | NEW |