OLD | NEW |
1 // Copyright (c) 2014 the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014 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 import "dart:math" show pow; | 5 import "dart:math" show pow; |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 | 7 |
8 const whiteSpace = const [ | 8 const whiteSpace = const [ |
9 "", | 9 "", |
10 "\x09", | 10 "\x09", |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 } | 107 } |
108 | 108 |
109 void testFail(String source) { | 109 void testFail(String source) { |
110 var object = new Object(); | 110 var object = new Object(); |
111 Expect.throws(() { | 111 Expect.throws(() { |
112 double.parse(source, (s) { | 112 double.parse(source, (s) { |
113 Expect.equals(source, s); | 113 Expect.equals(source, s); |
114 throw object; | 114 throw object; |
115 }); | 115 }); |
116 }, (e) => identical(object, e), "Fail: '$source'"); | 116 }, (e) => identical(object, e), "Fail: '$source'"); |
| 117 Expect.equals(1.5, double.parse(source, (s) => 1.5)); |
117 } | 118 } |
118 | 119 |
119 void main() { | 120 void main() { |
120 testDouble(0.0); | 121 testDouble(0.0); |
121 testDouble(5e-324); | 122 testDouble(5e-324); |
122 testDouble(2.225073858507201e-308); | 123 testDouble(2.225073858507201e-308); |
123 testDouble(2.2250738585072014e-308); | 124 testDouble(2.2250738585072014e-308); |
124 testDouble(0.49999999999999994); | 125 testDouble(0.49999999999999994); |
125 testDouble(0.5); | 126 testDouble(0.5); |
126 testDouble(0.50000000000000006); | 127 testDouble(0.50000000000000006); |
(...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1148 testFail("INFINITY"); | 1149 testFail("INFINITY"); |
1149 testFail("1.#INF"); | 1150 testFail("1.#INF"); |
1150 testFail("inf"); | 1151 testFail("inf"); |
1151 testFail("nan"); | 1152 testFail("nan"); |
1152 testFail("NAN"); | 1153 testFail("NAN"); |
1153 testFail("1.#IND"); | 1154 testFail("1.#IND"); |
1154 testFail("indef"); | 1155 testFail("indef"); |
1155 testFail("qnan"); | 1156 testFail("qnan"); |
1156 testFail("snan"); | 1157 testFail("snan"); |
1157 } | 1158 } |
OLD | NEW |