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 // Dart test program for testing the instanceof operation. | 4 // Dart test program for testing the instanceof operation. |
5 | 5 |
| 6 #library('intrinsified_methods_test'); |
| 7 #import('dart:math'); |
6 | 8 |
7 testIsNegative() { | 9 testIsNegative() { |
8 Expect.isFalse((12.0).isNegative()); | 10 Expect.isFalse((12.0).isNegative()); |
9 Expect.isTrue((-12.0).isNegative()); | 11 Expect.isTrue((-12.0).isNegative()); |
10 Expect.isFalse((double.NAN).isNegative()); | 12 Expect.isFalse((double.NAN).isNegative()); |
11 Expect.isFalse((0.0).isNegative()); | 13 Expect.isFalse((0.0).isNegative()); |
12 Expect.isTrue((-0.0).isNegative()); | 14 Expect.isTrue((-0.0).isNegative()); |
13 Expect.isFalse((double.INFINITY).isNegative()); | 15 Expect.isFalse((double.INFINITY).isNegative()); |
14 Expect.isTrue((double.NEGATIVE_INFINITY).isNegative()); | 16 Expect.isTrue((double.NEGATIVE_INFINITY).isNegative()); |
15 } | 17 } |
16 | 18 |
17 testIsNaN() { | 19 testIsNaN() { |
18 Expect.isFalse((1.0).isNaN()); | 20 Expect.isFalse((1.0).isNaN()); |
19 Expect.isTrue((double.NAN).isNaN()); | 21 Expect.isTrue((double.NAN).isNaN()); |
20 } | 22 } |
21 | 23 |
22 | 24 |
23 testTrigonometric() { | 25 testTrigonometric() { |
24 Expect.approxEquals(1.0, Math.sin(Math.PI / 2.0), 0.0001); | 26 Expect.approxEquals(1.0, sin(PI / 2.0), 0.0001); |
25 Expect.approxEquals(1.0, Math.cos(0), 0.0001); | 27 Expect.approxEquals(1.0, cos(0), 0.0001); |
26 Expect.approxEquals(1.0, Math.cos(0.0), 0.0001); | 28 Expect.approxEquals(1.0, cos(0.0), 0.0001); |
27 } | 29 } |
28 | 30 |
29 num foo(int n) { | 31 num foo(int n) { |
30 var x; | 32 var x; |
31 for(var i = 0; i <= n; ++i) { | 33 for(var i = 0; i <= n; ++i) { |
32 Expect.equals(2.0, Math.sqrt(4.0)); | 34 Expect.equals(2.0, sqrt(4.0)); |
33 testIsNegative(); | 35 testIsNegative(); |
34 testIsNaN(); | 36 testIsNaN(); |
35 testTrigonometric(); | 37 testTrigonometric(); |
36 } | 38 } |
37 return x; | 39 return x; |
38 } | 40 } |
39 | 41 |
40 void main() { | 42 void main() { |
41 var m = foo(4000); | 43 var m = foo(4000); |
42 } | 44 } |
OLD | NEW |