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