mirror of
https://github.com/dart-lang/sdk
synced 2024-10-03 00:09:20 +00:00
Add tryParse alternatives to parseFunctions.
Deprecate `onError` arguments to parse methods. Change-Id: Iac1d87416abc8a73ce1853edffab49df8a8cb5fe Reviewed-on: https://dart-review.googlesource.com/50723 Commit-Queue: Lasse R.H. Nielsen <lrn@google.com> Reviewed-by: Samuel Rawlins <srawlins@google.com> Reviewed-by: Leaf Petersen <leafp@google.com>
This commit is contained in:
parent
58a6bfd974
commit
7cc4d76a30
|
@ -2,6 +2,14 @@
|
||||||
(Add new changes here, and they will be copied to the
|
(Add new changes here, and they will be copied to the
|
||||||
change section for the next dev version)
|
change section for the next dev version)
|
||||||
|
|
||||||
|
### Core library changes
|
||||||
|
|
||||||
|
* `dart:core`
|
||||||
|
* Added `tryParse` static method to `int`, `double`, `num`, `BigInt`,
|
||||||
|
`Uri` and `DateTime`.
|
||||||
|
* Deprecated `onError` parameter on `int.parse`, `double.parse`
|
||||||
|
and `num.parse`.
|
||||||
|
|
||||||
### Tool Changes
|
### Tool Changes
|
||||||
|
|
||||||
#### Analyzer
|
#### Analyzer
|
||||||
|
|
|
@ -135,13 +135,21 @@ class Expando<T> {
|
||||||
static int _keyCount = 0;
|
static int _keyCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Null _kNull(_) => null;
|
||||||
|
|
||||||
@patch
|
@patch
|
||||||
class int {
|
class int {
|
||||||
@patch
|
@patch
|
||||||
static int parse(String source, {int radix, int onError(String source)}) {
|
static int parse(String source,
|
||||||
|
{int radix, @deprecated int onError(String source)}) {
|
||||||
return Primitives.parseInt(source, radix, onError);
|
return Primitives.parseInt(source, radix, onError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@patch
|
||||||
|
static int tryParse(String source, {int radix}) {
|
||||||
|
return Primitives.parseInt(source, radix, _kNull);
|
||||||
|
}
|
||||||
|
|
||||||
@patch
|
@patch
|
||||||
factory int.fromEnvironment(String name, {int defaultValue}) {
|
factory int.fromEnvironment(String name, {int defaultValue}) {
|
||||||
// ignore: const_constructor_throws_exception
|
// ignore: const_constructor_throws_exception
|
||||||
|
@ -153,9 +161,15 @@ class int {
|
||||||
@patch
|
@patch
|
||||||
class double {
|
class double {
|
||||||
@patch
|
@patch
|
||||||
static double parse(String source, [double onError(String source)]) {
|
static double parse(String source,
|
||||||
|
[@deprecated double onError(String source)]) {
|
||||||
return Primitives.parseDouble(source, onError);
|
return Primitives.parseDouble(source, onError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@patch
|
||||||
|
static double tryParse(String source) {
|
||||||
|
return Primitives.parseDouble(source, _kNull);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@patch
|
@patch
|
||||||
|
@ -171,6 +185,10 @@ class BigInt implements Comparable<BigInt> {
|
||||||
static BigInt parse(String source, {int radix}) =>
|
static BigInt parse(String source, {int radix}) =>
|
||||||
_BigIntImpl.parse(source, radix: radix);
|
_BigIntImpl.parse(source, radix: radix);
|
||||||
|
|
||||||
|
@patch
|
||||||
|
static BigInt tryParse(String source, {int radix}) =>
|
||||||
|
_BigIntImpl._tryParse(source, radix: radix);
|
||||||
|
|
||||||
@patch
|
@patch
|
||||||
factory BigInt.from(num value) = _BigIntImpl.from;
|
factory BigInt.from(num value) = _BigIntImpl.from;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,10 @@ class BigInt implements Comparable<BigInt> {
|
||||||
static BigInt parse(String source, {int radix}) =>
|
static BigInt parse(String source, {int radix}) =>
|
||||||
_BigIntImpl.parse(source, radix: radix);
|
_BigIntImpl.parse(source, radix: radix);
|
||||||
|
|
||||||
|
@patch
|
||||||
|
static BigInt tryParse(String source, {int radix}) =>
|
||||||
|
_BigIntImpl._tryParse(source, radix: radix);
|
||||||
|
|
||||||
@patch
|
@patch
|
||||||
factory BigInt.from(num value) => new _BigIntImpl.from(value);
|
factory BigInt.from(num value) => new _BigIntImpl.from(value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,8 @@ class double {
|
||||||
}
|
}
|
||||||
|
|
||||||
@patch
|
@patch
|
||||||
static double parse(String source, [double onError(String source)]) {
|
static double parse(String source,
|
||||||
|
[@deprecated double onError(String source)]) {
|
||||||
var result = _parse(source);
|
var result = _parse(source);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
if (onError == null) throw new FormatException("Invalid double", source);
|
if (onError == null) throw new FormatException("Invalid double", source);
|
||||||
|
@ -111,4 +112,7 @@ class double {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@patch
|
||||||
|
static double tryParse(String source) => _parse(source);
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,6 +107,22 @@ class int {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@patch
|
||||||
|
static int tryParse(String source, {int radix}) {
|
||||||
|
if (source == null) throw new ArgumentError("The source must not be null");
|
||||||
|
if (source.isEmpty) return null;
|
||||||
|
if (radix == null || radix == 10) {
|
||||||
|
// Try parsing immediately, without trimming whitespace.
|
||||||
|
int result = _tryParseSmi(source, 0, source.length - 1);
|
||||||
|
if (result != null) return result;
|
||||||
|
} else if (radix < 2 || radix > 36) {
|
||||||
|
throw new RangeError("Radix $radix not in range 2..36");
|
||||||
|
}
|
||||||
|
return _parse(source, radix, _kNull);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Null _kNull(_) => null;
|
||||||
|
|
||||||
static int _throwFormatException(onError, source, index, radix) {
|
static int _throwFormatException(onError, source, index, radix) {
|
||||||
if (onError != null) return onError(source);
|
if (onError != null) return onError(source);
|
||||||
if (radix == null) {
|
if (radix == null) {
|
||||||
|
|
|
@ -166,20 +166,34 @@ class Expando<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Null _kNull(_) => null;
|
||||||
|
|
||||||
@patch
|
@patch
|
||||||
class int {
|
class int {
|
||||||
@patch
|
@patch
|
||||||
static int parse(String source, {int radix, int onError(String source)}) {
|
static int parse(String source,
|
||||||
|
{int radix, @deprecated int onError(String source)}) {
|
||||||
return Primitives.parseInt(source, radix, onError);
|
return Primitives.parseInt(source, radix, onError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@patch
|
||||||
|
static int tryParse(String source, {int radix}) {
|
||||||
|
return Primitives.parseInt(source, radix, _kNull);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@patch
|
@patch
|
||||||
class double {
|
class double {
|
||||||
@patch
|
@patch
|
||||||
static double parse(String source, [double onError(String source)]) {
|
static double parse(String source,
|
||||||
|
[@deprecated double onError(String source)]) {
|
||||||
return Primitives.parseDouble(source, onError);
|
return Primitives.parseDouble(source, onError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@patch
|
||||||
|
static double tryParse(String source) {
|
||||||
|
return Primitives.parseDouble(source, _kNull);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@patch
|
@patch
|
||||||
|
@ -195,6 +209,10 @@ class BigInt implements Comparable<BigInt> {
|
||||||
static BigInt parse(String source, {int radix}) =>
|
static BigInt parse(String source, {int radix}) =>
|
||||||
_BigIntImpl.parse(source, radix: radix);
|
_BigIntImpl.parse(source, radix: radix);
|
||||||
|
|
||||||
|
@patch
|
||||||
|
static BigInt tryParse(String source, {int radix}) =>
|
||||||
|
_BigIntImpl._tryParse(source, radix: radix);
|
||||||
|
|
||||||
@patch
|
@patch
|
||||||
factory BigInt.from(num value) = _BigIntImpl.from;
|
factory BigInt.from(num value) = _BigIntImpl.from;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,15 @@ abstract class BigInt implements Comparable<BigInt> {
|
||||||
*/
|
*/
|
||||||
external static BigInt parse(String source, {int radix});
|
external static BigInt parse(String source, {int radix});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses [source] as a, possibly signed, integer literal and returns its
|
||||||
|
* value.
|
||||||
|
*
|
||||||
|
* As [parse] except that this method returns `null` if the input is not
|
||||||
|
* valid
|
||||||
|
*/
|
||||||
|
external static BigInt tryParse(String source, {int radix});
|
||||||
|
|
||||||
/// Allocates a big integer from the provided [value] number.
|
/// Allocates a big integer from the provided [value] number.
|
||||||
external factory BigInt.from(num value);
|
external factory BigInt.from(num value);
|
||||||
|
|
||||||
|
|
|
@ -317,28 +317,7 @@ class DateTime implements Comparable<DateTime> {
|
||||||
// TODO(lrn): restrict incorrect values like 2003-02-29T50:70:80.
|
// TODO(lrn): restrict incorrect values like 2003-02-29T50:70:80.
|
||||||
// Or not, that may be a breaking change.
|
// Or not, that may be a breaking change.
|
||||||
static DateTime parse(String formattedString) {
|
static DateTime parse(String formattedString) {
|
||||||
/*
|
var re = _parseFormat;
|
||||||
* date ::= yeardate time_opt timezone_opt
|
|
||||||
* yeardate ::= year colon_opt month colon_opt day
|
|
||||||
* year ::= sign_opt digit{4,6}
|
|
||||||
* colon_opt :: <empty> | ':'
|
|
||||||
* sign ::= '+' | '-'
|
|
||||||
* sign_opt ::= <empty> | sign
|
|
||||||
* month ::= digit{2}
|
|
||||||
* day ::= digit{2}
|
|
||||||
* time_opt ::= <empty> | (' ' | 'T') hour minutes_opt
|
|
||||||
* minutes_opt ::= <empty> | colon_opt digit{2} seconds_opt
|
|
||||||
* seconds_opt ::= <empty> | colon_opt digit{2} millis_opt
|
|
||||||
* micros_opt ::= <empty> | '.' digit{1,6}
|
|
||||||
* timezone_opt ::= <empty> | space_opt timezone
|
|
||||||
* space_opt :: ' ' | <empty>
|
|
||||||
* timezone ::= 'z' | 'Z' | sign digit{2} timezonemins_opt
|
|
||||||
* timezonemins_opt ::= <empty> | colon_opt digit{2}
|
|
||||||
*/
|
|
||||||
final RegExp re = new RegExp(r'^([+-]?\d{4,6})-?(\d\d)-?(\d\d)' // Day part.
|
|
||||||
r'(?:[ T](\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d{1,6}))?)?)?' // Time part.
|
|
||||||
r'( ?[zZ]| ?([-+])(\d\d)(?::?(\d\d))?)?)?$'); // Timezone part.
|
|
||||||
|
|
||||||
Match match = re.firstMatch(formattedString);
|
Match match = re.firstMatch(formattedString);
|
||||||
if (match != null) {
|
if (match != null) {
|
||||||
int parseIntOrZero(String matched) {
|
int parseIntOrZero(String matched) {
|
||||||
|
@ -400,6 +379,15 @@ class DateTime implements Comparable<DateTime> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DateTime tryParse(String formattedString) {
|
||||||
|
// TODO: Optimize to avoid throwing.
|
||||||
|
try {
|
||||||
|
return parse(formattedString);
|
||||||
|
} on FormatException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static const int _maxMillisecondsSinceEpoch = 8640000000000000;
|
static const int _maxMillisecondsSinceEpoch = 8640000000000000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -904,4 +892,27 @@ class DateTime implements Comparable<DateTime> {
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
external int get weekday;
|
external int get weekday;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* date ::= yeardate time_opt timezone_opt
|
||||||
|
* yeardate ::= year colon_opt month colon_opt day
|
||||||
|
* year ::= sign_opt digit{4,6}
|
||||||
|
* colon_opt :: <empty> | ':'
|
||||||
|
* sign ::= '+' | '-'
|
||||||
|
* sign_opt ::= <empty> | sign
|
||||||
|
* month ::= digit{2}
|
||||||
|
* day ::= digit{2}
|
||||||
|
* time_opt ::= <empty> | (' ' | 'T') hour minutes_opt
|
||||||
|
* minutes_opt ::= <empty> | colon_opt digit{2} seconds_opt
|
||||||
|
* seconds_opt ::= <empty> | colon_opt digit{2} millis_opt
|
||||||
|
* micros_opt ::= <empty> | '.' digit{1,6}
|
||||||
|
* timezone_opt ::= <empty> | space_opt timezone
|
||||||
|
* space_opt :: ' ' | <empty>
|
||||||
|
* timezone ::= 'z' | 'Z' | sign digit{2} timezonemins_opt
|
||||||
|
* timezonemins_opt ::= <empty> | colon_opt digit{2}
|
||||||
|
*/
|
||||||
|
static final RegExp _parseFormat = new RegExp(
|
||||||
|
r'^([+-]?\d{4,6})-?(\d\d)-?(\d\d)' // Day part.
|
||||||
|
r'(?:[ T](\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d{1,6}))?)?)?' // Time part.
|
||||||
|
r'( ?[zZ]| ?([-+])(\d\d)(?::?(\d\d))?)?)?$'); // Timezone part.
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,6 +210,19 @@ abstract class double extends num {
|
||||||
* "1234E+7"
|
* "1234E+7"
|
||||||
* "+.12e-9"
|
* "+.12e-9"
|
||||||
* "-NaN"
|
* "-NaN"
|
||||||
|
*
|
||||||
|
* The [onError] parameter is deprecated and will be removed.
|
||||||
|
* Instead of `double.parse(string, (string) { ... })`,
|
||||||
|
* you should use `double.tryParse(string) ?? (...)`.
|
||||||
*/
|
*/
|
||||||
external static double parse(String source, [double onError(String source)]);
|
external static double parse(String source,
|
||||||
|
[@deprecated double onError(String source)]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse [source] as an double literal and return its value.
|
||||||
|
*
|
||||||
|
* Like [parse] except that this function returns `null` for invalid inputs
|
||||||
|
* instead of throwing.
|
||||||
|
*/
|
||||||
|
external static double tryParse(String source);
|
||||||
}
|
}
|
||||||
|
|
|
@ -319,7 +319,19 @@ abstract class int extends num {
|
||||||
*
|
*
|
||||||
* The [onError] function is only invoked if [source] is a [String]. It is
|
* The [onError] function is only invoked if [source] is a [String]. It is
|
||||||
* not invoked if the [source] is, for example, `null`.
|
* not invoked if the [source] is, for example, `null`.
|
||||||
|
*
|
||||||
|
* The [onError] parameter is deprecated and will be removed.
|
||||||
|
* Instead of `int.parse(string, onError: (string) { ... })`,
|
||||||
|
* you should use `int.tryParse(string) ?? (...)`.
|
||||||
*/
|
*/
|
||||||
external static int parse(String source,
|
external static int parse(String source,
|
||||||
{int radix, int onError(String source)});
|
{int radix, @deprecated int onError(String source)});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse [source] as a, possibly signed, integer literal and return its value.
|
||||||
|
*
|
||||||
|
* Like [parse] except that this function returns `null` for invalid inputs
|
||||||
|
* instead of throwing.
|
||||||
|
*/
|
||||||
|
external static int tryParse(String source, {int radix});
|
||||||
}
|
}
|
||||||
|
|
|
@ -462,18 +462,30 @@ abstract class num implements Comparable<num> {
|
||||||
* For any number `n`, this function satisfies
|
* For any number `n`, this function satisfies
|
||||||
* `identical(n, num.parse(n.toString()))` (except when `n` is a NaN `double`
|
* `identical(n, num.parse(n.toString()))` (except when `n` is a NaN `double`
|
||||||
* with a payload).
|
* with a payload).
|
||||||
|
*
|
||||||
|
* The [onError] parameter is deprecated and will be removed.
|
||||||
|
* Instead of `num.parse(string, (string) { ... })`,
|
||||||
|
* you should use `num.tryParse(string) ?? (...)`.
|
||||||
*/
|
*/
|
||||||
static num parse(String input, [num onError(String input)]) {
|
static num parse(String input, [@deprecated num onError(String input)]) {
|
||||||
String source = input.trim();
|
num result = tryParse(input);
|
||||||
// TODO(lrn): Optimize to detect format and result type in one check.
|
|
||||||
num result = int.parse(source, onError: _returnIntNull);
|
|
||||||
if (result != null) return result;
|
|
||||||
result = double.parse(source, _returnDoubleNull);
|
|
||||||
if (result != null) return result;
|
if (result != null) return result;
|
||||||
if (onError == null) throw new FormatException(input);
|
if (onError == null) throw new FormatException(input);
|
||||||
return onError(input);
|
return onError(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses a string containing a number literal into a number.
|
||||||
|
*
|
||||||
|
* Like [parse] except that this function returns `null` for invalid inputs
|
||||||
|
* instead of throwing.
|
||||||
|
*/
|
||||||
|
static num tryParse(String input) {
|
||||||
|
String source = input.trim();
|
||||||
|
// TODO(lrn): Optimize to detect format and result type in one check.
|
||||||
|
return int.tryParse(source) ?? double.tryParse(source);
|
||||||
|
}
|
||||||
|
|
||||||
/** Helper functions for [parse]. */
|
/** Helper functions for [parse]. */
|
||||||
static int _returnIntNull(String _) => null;
|
static int _returnIntNull(String _) => null;
|
||||||
static double _returnDoubleNull(String _) => null;
|
static double _returnDoubleNull(String _) => null;
|
||||||
|
|
|
@ -309,20 +309,20 @@ abstract class String implements Comparable<String>, Pattern {
|
||||||
*
|
*
|
||||||
* If the string contains leading or trailing whitespace, a new string with no
|
* If the string contains leading or trailing whitespace, a new string with no
|
||||||
* leading and no trailing whitespace is returned:
|
* leading and no trailing whitespace is returned:
|
||||||
*
|
* ```dart
|
||||||
* '\tDart is fun\n'.trim(); // 'Dart is fun'
|
* '\tDart is fun\n'.trim(); // 'Dart is fun'
|
||||||
*
|
* ```
|
||||||
* Otherwise, the original string itself is returned:
|
* Otherwise, the original string itself is returned:
|
||||||
*
|
* ```dart
|
||||||
* var str1 = 'Dart';
|
* var str1 = 'Dart';
|
||||||
* var str2 = str1.trim();
|
* var str2 = str1.trim();
|
||||||
* identical(str1, str2); // true
|
* identical(str1, str2); // true
|
||||||
*
|
* ```
|
||||||
* Whitespace is defined by the Unicode White_Space property (as defined in
|
* Whitespace is defined by the Unicode White_Space property (as defined in
|
||||||
* version 6.2 or later) and the BOM character, 0xFEFF.
|
* version 6.2 or later) and the BOM character, 0xFEFF.
|
||||||
*
|
*
|
||||||
* Here is the list of trimmed characters (following version 6.3):
|
* Here is the list of trimmed characters according to Unicode version 6.3:
|
||||||
*
|
* ```
|
||||||
* 0009..000D ; White_Space # Cc <control-0009>..<control-000D>
|
* 0009..000D ; White_Space # Cc <control-0009>..<control-000D>
|
||||||
* 0020 ; White_Space # Zs SPACE
|
* 0020 ; White_Space # Zs SPACE
|
||||||
* 0085 ; White_Space # Cc <control-0085>
|
* 0085 ; White_Space # Cc <control-0085>
|
||||||
|
@ -336,6 +336,10 @@ abstract class String implements Comparable<String>, Pattern {
|
||||||
* 3000 ; White_Space # Zs IDEOGRAPHIC SPACE
|
* 3000 ; White_Space # Zs IDEOGRAPHIC SPACE
|
||||||
*
|
*
|
||||||
* FEFF ; BOM ZERO WIDTH NO_BREAK SPACE
|
* FEFF ; BOM ZERO WIDTH NO_BREAK SPACE
|
||||||
|
* ```
|
||||||
|
* Some later versions of Unicode do not include U+0085 as a whitespace
|
||||||
|
* character. Whether it is trimmed depends on the Unicode version
|
||||||
|
* used by the system.
|
||||||
*/
|
*/
|
||||||
String trim();
|
String trim();
|
||||||
|
|
||||||
|
|
|
@ -1013,6 +1013,23 @@ abstract class Uri {
|
||||||
pathStart, queryStart, fragmentStart, scheme);
|
pathStart, queryStart, fragmentStart, scheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new `Uri` object by parsing a URI string.
|
||||||
|
*
|
||||||
|
* If [start] and [end] are provided, only the substring from `start`
|
||||||
|
* to `end` is parsed as a URI.
|
||||||
|
*
|
||||||
|
* Returns `null` if the string is not valid as a URI or URI reference.
|
||||||
|
*/
|
||||||
|
static Uri tryParse(String uri, [int start = 0, int end]) {
|
||||||
|
// TODO: Optimize to avoid throwing-and-recatching.
|
||||||
|
try {
|
||||||
|
return parse(uri, start, end);
|
||||||
|
} on FormatException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encode the string [component] using percent-encoding to make it
|
* Encode the string [component] using percent-encoding to make it
|
||||||
* safe for literal use as a URI component.
|
* safe for literal use as a URI component.
|
||||||
|
|
|
@ -586,13 +586,6 @@ from_environment_const_type_undefined_test/14: MissingCompileTimeError
|
||||||
from_environment_const_type_undefined_test/16: MissingCompileTimeError
|
from_environment_const_type_undefined_test/16: MissingCompileTimeError
|
||||||
iterable_to_set_test: RuntimeError # is-checks do not implement strong mode type system
|
iterable_to_set_test: RuntimeError # is-checks do not implement strong mode type system
|
||||||
|
|
||||||
[ $compiler == dartdevc || $compiler == dart2analyzer && $strong ]
|
|
||||||
double_parse_test/01: Skip # Temporarily disable the following tests until we figure out why they started failing.
|
|
||||||
double_parse_test/02: Skip # Temporarily disable the following tests until we figure out why they started failing.
|
|
||||||
double_parse_test/03: Skip # Temporarily disable the following tests until we figure out why they started failing.
|
|
||||||
double_parse_test/04: Skip # Temporarily disable the following tests until we figure out why they started failing.
|
|
||||||
double_parse_test/none: Skip # Temporarily disable the following tests until we figure out why they started failing.
|
|
||||||
|
|
||||||
[ $compiler == dartkp || $compiler == precompiler ]
|
[ $compiler == dartkp || $compiler == precompiler ]
|
||||||
apply3_test: SkipByDesign
|
apply3_test: SkipByDesign
|
||||||
dynamic_nosuchmethod_test: SkipByDesign
|
dynamic_nosuchmethod_test: SkipByDesign
|
||||||
|
|
|
@ -15,9 +15,7 @@ const whiteSpace = const [
|
||||||
"\x0c",
|
"\x0c",
|
||||||
"\x0d",
|
"\x0d",
|
||||||
// JS implementations disagree on U+0085 being whitespace.
|
// JS implementations disagree on U+0085 being whitespace.
|
||||||
// U+0085 does not work well with testParseWhiteSpace, so place
|
// U+0085 does not work well with testParseWhiteSpace, so omit it.
|
||||||
// in its own multitest.
|
|
||||||
"\x85", //# 01: ok
|
|
||||||
"\xa0",
|
"\xa0",
|
||||||
"\u1680",
|
"\u1680",
|
||||||
"\u2000",
|
"\u2000",
|
||||||
|
@ -232,27 +230,27 @@ void main() {
|
||||||
"4555072551893136908362547791869486679949683240497058210285131854"
|
"4555072551893136908362547791869486679949683240497058210285131854"
|
||||||
"51396213837722826145437693412532098591327667236328125",
|
"51396213837722826145437693412532098591327667236328125",
|
||||||
0.0);
|
0.0);
|
||||||
testParse( //# 03: ok
|
testParse(
|
||||||
"0.00000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0.00000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000024703282292062327208828439643411068627545332140664243314532" //# 03: ok
|
"0000024703282292062327208828439643411068627545332140664243314532"
|
||||||
"8041234170109088178685677591650492652607243027730579814636067699" //# 03: ok
|
"8041234170109088178685677591650492652607243027730579814636067699"
|
||||||
"1112238669661707327453443265068702897439863329200619332642599205" //# 03: ok
|
"1112238669661707327453443265068702897439863329200619332642599205"
|
||||||
"1806252781222000513169502627641523911022607448403553068808609405" //# 03: ok
|
"1806252781222000513169502627641523911022607448403553068808609405"
|
||||||
"1727798181294290864842608522062097649849550765341204993205100587" //# 03: ok
|
"1727798181294290864842608522062097649849550765341204993205100587"
|
||||||
"2127469658709242016690593998242808606978027857019419997429604579" //# 03: ok
|
"2127469658709242016690593998242808606978027857019419997429604579"
|
||||||
"7572623273334010723772922131119806567715298322567005234345331218" //# 03: ok
|
"7572623273334010723772922131119806567715298322567005234345331218"
|
||||||
"5169920860031716486480793611343761679481328431956040281530986197" //# 03: ok
|
"5169920860031716486480793611343761679481328431956040281530986197"
|
||||||
"8304604971452253283193290744072288902141724247846767401941767720" //# 03: ok
|
"8304604971452253283193290744072288902141724247846767401941767720"
|
||||||
"8561650585989659548591956327689896895290365125294085321852619688" //# 03: ok
|
"8561650585989659548591956327689896895290365125294085321852619688"
|
||||||
"9863888974446146846024033780172178553364579041996676675092137151" //# 03: ok
|
"9863888974446146846024033780172178553364579041996676675092137151"
|
||||||
"9705456298034409473812692774776868254618683783877327369245051207" //# 03: ok
|
"9705456298034409473812692774776868254618683783877327369245051207"
|
||||||
"5931578479504396230612962142122846982018227555473696607567828620" //# 03: ok
|
"5931578479504396230612962142122846982018227555473696607567828620"
|
||||||
"5497859173707553281928994692862033843994140625", //# 03: ok
|
"5497859173707553281928994692862033843994140625",
|
||||||
5e-324); //# 03: ok
|
5e-324);
|
||||||
testParse(
|
testParse(
|
||||||
"0.00000000000000000000000000000000000000000000000000000000000000"
|
"0.00000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000"
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
|
@ -375,46 +373,46 @@ void main() {
|
||||||
"8136843040991207538774075715754306035963544889052606784864342758"
|
"8136843040991207538774075715754306035963544889052606784864342758"
|
||||||
"900428165258489343614201061427593231201171875",
|
"900428165258489343614201061427593231201171875",
|
||||||
5e-324);
|
5e-324);
|
||||||
testParse( //# 02: ok
|
testParse(
|
||||||
"0.00000000000000000000000000000000000000000000000000000000000000" //# 02: ok
|
"0.00000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 02: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 02: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 02: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 02: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000074109846876186981626485318930233205854758970392148714663837" //# 02: ok
|
"0000074109846876186981626485318930233205854758970392148714663837"
|
||||||
"8523751013260905313127797949754542453988569694847043168576596389" //# 02: ok
|
"8523751013260905313127797949754542453988569694847043168576596389"
|
||||||
"9850655339096945981621940161728171894510697854671067917687257517" //# 02: ok
|
"9850655339096945981621940161728171894510697854671067917687257517"
|
||||||
"7347315553307795408549809608457500958111373034747658096871009590" //# 02: ok
|
"7347315553307795408549809608457500958111373034747658096871009590"
|
||||||
"9754422710047573078097111189357848386756539987835030152280559340" //# 02: ok
|
"9754422710047573078097111189357848386756539987835030152280559340"
|
||||||
"4659373979179073872386829939581848166016912201945649993128979841" //# 02: ok
|
"4659373979179073872386829939581848166016912201945649993128979841"
|
||||||
"1362062484498678713572180352209017023903285791732520220528974020" //# 02: ok
|
"1362062484498678713572180352209017023903285791732520220528974020"
|
||||||
"8029068540216066123755499834026713000358124864790413857434018755" //# 02: ok
|
"8029068540216066123755499834026713000358124864790413857434018755"
|
||||||
"2090159017259254714629617513415977493871857473787096164563890871" //# 02: ok
|
"2090159017259254714629617513415977493871857473787096164563890871"
|
||||||
"8119841271673056017045493004705269590165763776884908267986972573" //# 02: ok
|
"8119841271673056017045493004705269590165763776884908267986972573"
|
||||||
"3665217655679410725087643375608460039849049721491174630855395563" //# 02: ok
|
"3665217655679410725087643375608460039849049721491174630855395563"
|
||||||
"54188641513168478436313080237596295773983001708984375", //# 02: ok
|
"54188641513168478436313080237596295773983001708984375",
|
||||||
1e-323); //# 02: ok
|
1e-323);
|
||||||
testParse( //# 03: ok
|
testParse(
|
||||||
"0.00000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0.00000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000074109846876186981626485318930233205873343654412044724850344" //# 03: ok
|
"0000074109846876186981626485318930233205873343654412044724850344"
|
||||||
"8923718677971811461747287833219166123210675953743507352131000861" //# 03: ok
|
"8923718677971811461747287833219166123210675953743507352131000861"
|
||||||
"5508029119022396648780866584046796426383292609958261304514284249" //# 03: ok
|
"5508029119022396648780866584046796426383292609958261304514284249"
|
||||||
"6061610746879932829188941791435548141415672575056325503240888674" //# 03: ok
|
"6061610746879932829188941791435548141415672575056325503240888674"
|
||||||
"0040403932604439422384254107243478095284614859960753370503720954" //# 03: ok
|
"0040403932604439422384254107243478095284614859960753370503720954"
|
||||||
"5808063977144841990843464643012899935961693114687389992568869106" //# 03: ok
|
"5808063977144841990843464643012899935961693114687389992568869106"
|
||||||
"5599267374834247685403237712975952143398358575711517208866987110" //# 03: ok
|
"5599267374834247685403237712975952143398358575711517208866987110"
|
||||||
"6349531233468788347546753834029761025748698485508885182206645314" //# 03: ok
|
"6349531233468788347546753834029761025748698485508885182206645314"
|
||||||
"0639262948657591471263120659283236968907400986955900192071499065" //# 03: ok
|
"0639262948657591471263120659283236968907400986955900192071499065"
|
||||||
"6496581595870337769532410323614883653969318176216473399700896902" //# 03: ok
|
"6496581595870337769532410323614883653969318176216473399700896902"
|
||||||
"4282850500785430600410615352213843786678841324490411560469406158" //# 03: ok
|
"4282850500785430600410615352213843786678841324490411560469406158"
|
||||||
"4550533979841101562169154890806946368370134291387467238490102415" //# 03: ok
|
"4550533979841101562169154890806946368370134291387467238490102415"
|
||||||
"1863156959008792461225924284245693964036455110947393215135657241" //# 03: ok
|
"1863156959008792461225924284245693964036455110947393215135657241"
|
||||||
"099571834741510656385798938572406768798828125", //# 03: ok
|
"099571834741510656385798938572406768798828125",
|
||||||
1e-323); //# 03: ok
|
1e-323);
|
||||||
testParse(
|
testParse(
|
||||||
"0.00000000000000000000000000000000000000000000000000000000000000"
|
"0.00000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000"
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
|
@ -495,27 +493,27 @@ void main() {
|
||||||
"0239620254961370692713747131027132020441991845959370908649389667"
|
"0239620254961370692713747131027132020441991845959370908649389667"
|
||||||
"01396213837722826145437693412532098591327667236328125",
|
"01396213837722826145437693412532098591327667236328125",
|
||||||
1.1125369292536007e-308);
|
1.1125369292536007e-308);
|
||||||
testParse( //# 03: ok
|
testParse(
|
||||||
"0.00000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0.00000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000011125369292" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000011125369292"
|
||||||
"5360093857793927928947412039400442434185228365340521456608629527" //# 03: ok
|
"5360093857793927928947412039400442434185228365340521456608629527"
|
||||||
"0200315929606120759250932815416474352736201659755028987189999989" //# 03: ok
|
"0200315929606120759250932815416474352736201659755028987189999989"
|
||||||
"3220987486513026766686796443888026815774211444057134206415720396" //# 03: ok
|
"3220987486513026766686796443888026815774211444057134206415720396"
|
||||||
"3510525564718487986029401249963455450110781777556316353975973978" //# 03: ok
|
"3510525564718487986029401249963455450110781777556316353975973978"
|
||||||
"4825173851725161436876623857879887229903814003929524302244972629" //# 03: ok
|
"4825173851725161436876623857879887229903814003929524302244972629"
|
||||||
"6795040225381805100879491255387164751912585073962051947893527710" //# 03: ok
|
"6795040225381805100879491255387164751912585073962051947893527710"
|
||||||
"5170790163081944841764003984818943810636714040207972316616704045" //# 03: ok
|
"5170790163081944841764003984818943810636714040207972316616704045"
|
||||||
"0220895038833513659790739432367709097880422198053807344762226099" //# 03: ok
|
"0220895038833513659790739432367709097880422198053807344762226099"
|
||||||
"3129277744388529754345873069706690065083079768940685222309466301" //# 03: ok
|
"3129277744388529754345873069706690065083079768940685222309466301"
|
||||||
"4235389404255004774284573740536646273496781023858510820692328908" //# 03: ok
|
"4235389404255004774284573740536646273496781023858510820692328908"
|
||||||
"0857253100067390568036719107632515767271783448958607838263400261" //# 03: ok
|
"0857253100067390568036719107632515767271783448958607838263400261"
|
||||||
"9271291212296536333081616208300526650104600844121842238490102415" //# 03: ok
|
"9271291212296536333081616208300526650104600844121842238490102415"
|
||||||
"1863156959008792461225924284245693964036455110947393215135657241" //# 03: ok
|
"1863156959008792461225924284245693964036455110947393215135657241"
|
||||||
"099571834741510656385798938572406768798828125", //# 03: ok
|
"099571834741510656385798938572406768798828125",
|
||||||
1.112536929253601e-308); //# 03: ok
|
1.112536929253601e-308);
|
||||||
testParse(
|
testParse(
|
||||||
"0.00000000000000000000000000000000000000000000000000000000000000"
|
"0.00000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000"
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
|
@ -577,46 +575,46 @@ void main() {
|
||||||
"8136843040991207538774075715754306035963544889052606784864342758"
|
"8136843040991207538774075715754306035963544889052606784864342758"
|
||||||
"900428165258489343614201061427593231201171875",
|
"900428165258489343614201061427593231201171875",
|
||||||
1.112536929253601e-308);
|
1.112536929253601e-308);
|
||||||
testParse( //# 02: ok
|
testParse(
|
||||||
"0.00000000000000000000000000000000000000000000000000000000000000" //# 02: ok
|
"0.00000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 02: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 02: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 02: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000011125369292" //# 02: ok
|
"0000000000000000000000000000000000000000000000000000011125369292"
|
||||||
"5360143264358512053601829696279729256322446286636762993074885578" //# 02: ok
|
"5360143264358512053601829696279729256322446286636762993074885578"
|
||||||
"5482848940402484819383308231788212319506475197423260249353326444" //# 02: ok
|
"5482848940402484819383308231788212319506475197423260249353326444"
|
||||||
"4130717265985540087275830129388183546908748591883986098046865342" //# 02: ok
|
"4130717265985540087275830129388183546908748591883986098046865342"
|
||||||
"9694440740018214171090142139290408905547397593746087678853434622" //# 02: ok
|
"9694440740018214171090142139290408905547397593746087678853434622"
|
||||||
"7708807769200010477987555066232823112546765790360487852208850575" //# 02: ok
|
"7708807769200010477987555066232823112546765790360487852208850575"
|
||||||
"8752599546868752897347409845010678425979078962517411943872958339" //# 02: ok
|
"8752599546868752897347409845010678425979078962517411943872958339"
|
||||||
"1841626929078828345647733525524686707077165117383988808631340302" //# 02: ok
|
"1841626929078828345647733525524686707077165117383988808631340302"
|
||||||
"3919811372391502185169818655049136406061931820528945258278945377" //# 02: ok
|
"3919811372391502185169818655049136406061931820528945258278945377"
|
||||||
"2640279824496362807465448266116748919295441238296611971177785355" //# 02: ok
|
"2640279824496362807465448266116748919295441238296611971177785355"
|
||||||
"4605209927839760366494651758097211936470402475783551200969719627" //# 02: ok
|
"4605209927839760366494651758097211936470402475783551200969719627"
|
||||||
"9349765358747644509438842714766105380341358326953487329219653376" //# 02: ok
|
"9349765358747644509438842714766105380341358326953487329219653376"
|
||||||
"04188641513168478436313080237596295773983001708984375", //# 02: ok
|
"04188641513168478436313080237596295773983001708984375",
|
||||||
1.1125369292536017e-308); //# 02: ok
|
1.1125369292536017e-308);
|
||||||
testParse( //# 03: ok
|
testParse(
|
||||||
"0.00000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0.00000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000011125369292" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000011125369292"
|
||||||
"5360143264358512053601829696279729256322464871320782889085072085" //# 03: ok
|
"5360143264358512053601829696279729256322464871320782889085072085"
|
||||||
"5882816605113390968002798115252835988728581456319724432907730915" //# 03: ok
|
"5882816605113390968002798115252835988728581456319724432907730915"
|
||||||
"9788091045910990754434756551706808078781343347171179484873892074" //# 03: ok
|
"9788091045910990754434756551706808078781343347171179484873892074"
|
||||||
"8408735933590351591729274322268456088851697134054755085223313705" //# 03: ok
|
"8408735933590351591729274322268456088851697134054755085223313705"
|
||||||
"7994788991756876822274697984118452821074840662486211070432012189" //# 03: ok
|
"7994788991756876822274697984118452821074840662486211070432012189"
|
||||||
"9901289544834521015804044548441730195923859875259151943312847604" //# 03: ok
|
"9901289544834521015804044548441730195923859875259151943312847604"
|
||||||
"6078831819414397317478790886291621826572237901362985796969353392" //# 03: ok
|
"6078831819414397317478790886291621826572237901362985796969353392"
|
||||||
"2240274065644224408961072655052184431452505441247416583051571936" //# 03: ok
|
"2240274065644224408961072655052184431452505441247416583051571936"
|
||||||
"1189383755894699564098951411984008394330984751465415998685393549" //# 03: ok
|
"1189383755894699564098951411984008394330984751465415998685393549"
|
||||||
"2981950252037042118981569077006826000273956875115116332683643956" //# 03: ok
|
"2981950252037042118981569077006826000273956875115116332683643956"
|
||||||
"9967398203853664384761814691371489127171149929952724258833663970" //# 03: ok
|
"9967398203853664384761814691371489127171149929952724258833663970"
|
||||||
"9550533979841101562169154890806946368370134291387467238490102415" //# 03: ok
|
"9550533979841101562169154890806946368370134291387467238490102415"
|
||||||
"1863156959008792461225924284245693964036455110947393215135657241" //# 03: ok
|
"1863156959008792461225924284245693964036455110947393215135657241"
|
||||||
"099571834741510656385798938572406768798828125", //# 03: ok
|
"099571834741510656385798938572406768798828125",
|
||||||
1.1125369292536017e-308); //# 03: ok
|
1.1125369292536017e-308);
|
||||||
testParse(
|
testParse(
|
||||||
"0.00000000000000000000000000000000000000000000000000000000000000"
|
"0.00000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000"
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
|
@ -696,27 +694,27 @@ void main() {
|
||||||
"5924167958029604477064946470184777360934300451421683607013647479"
|
"5924167958029604477064946470184777360934300451421683607013647479"
|
||||||
"51396213837722826145437693412532098591327667236328125",
|
"51396213837722826145437693412532098591327667236328125",
|
||||||
2.2250738585072014e-308);
|
2.2250738585072014e-308);
|
||||||
testParse( //# 03: ok
|
testParse(
|
||||||
"0.00000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0.00000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000022250738585" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000022250738585"
|
||||||
"0720163012305563795567615250361241457301819893006892300968851267" //# 03: ok
|
"0720163012305563795567615250361241457301819893006892300968851267"
|
||||||
"7159413856747700265506443097450144218254107162331246067966730043" //# 03: ok
|
"7159413856747700265506443097450144218254107162331246067966730043"
|
||||||
"7501049413401620872340686411548038468172262181270052386775328221" //# 03: ok
|
"7501049413401620872340686411548038468172262181270052386775328221"
|
||||||
"5857650751428906748569733780796363397546806336554745935958399010" //# 03: ok
|
"5857650751428906748569733780796363397546806336554745935958399010"
|
||||||
"2779558910877598836767067734754861955694039806454982002173263865" //# 03: ok
|
"2779558910877598836767067734754861955694039806454982002173263865"
|
||||||
"0888265793071484125840071160815995011874751834533813898637506208" //# 03: ok
|
"0888265793071484125840071160815995011874751834533813898637506208"
|
||||||
"5650354607662094473839557158134613493810593365859440904719070326" //# 03: ok
|
"5650354607662094473839557158134613493810593365859440904719070326"
|
||||||
"6111637871008949721205058253390132503584229153792338745607152721" //# 03: ok
|
"6111637871008949721205058253390132503584229153792338745607152721"
|
||||||
"3679398551625637847181703822407461490506663533450201028923360785" //# 03: ok
|
"3679398551625637847181703822407461490506663533450201028923360785"
|
||||||
"0720758060421709123733732493928588619801419722757153753675075962" //# 03: ok
|
"0720758060421709123733732493928588619801419722757153753675075962"
|
||||||
"6541800803135624352387918446790161107764092054420920536627658074" //# 03: ok
|
"6541800803135624352387918446790161107764092054420920536627658074"
|
||||||
"4271291212296536333081616208300526650104600844121842238490102415" //# 03: ok
|
"4271291212296536333081616208300526650104600844121842238490102415"
|
||||||
"1863156959008792461225924284245693964036455110947393215135657241" //# 03: ok
|
"1863156959008792461225924284245693964036455110947393215135657241"
|
||||||
"099571834741510656385798938572406768798828125", //# 03: ok
|
"099571834741510656385798938572406768798828125",
|
||||||
2.225073858507202e-308); //# 03: ok
|
2.225073858507202e-308);
|
||||||
testParse(
|
testParse(
|
||||||
"0.00000000000000000000000000000000000000000000000000000000000000"
|
"0.00000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000"
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
|
@ -778,46 +776,46 @@ void main() {
|
||||||
"8136843040991207538774075715754306035963544889052606784864342758"
|
"8136843040991207538774075715754306035963544889052606784864342758"
|
||||||
"900428165258489343614201061427593231201171875",
|
"900428165258489343614201061427593231201171875",
|
||||||
2.225073858507202e-308);
|
2.225073858507202e-308);
|
||||||
testParse( //# 03: ok
|
testParse(
|
||||||
"0.00000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0.00000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000022250738585" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000022250738585"
|
||||||
"0720212418870147920222032907240528279439037814303133837435107319" //# 03: ok
|
"0720212418870147920222032907240528279439037814303133837435107319"
|
||||||
"2441946867544064325638818513821882185024380699999477330130056498" //# 03: ok
|
"2441946867544064325638818513821882185024380699999477330130056498"
|
||||||
"8410779192874134192929720097048195199306799329096904278406473168" //# 03: ok
|
"8410779192874134192929720097048195199306799329096904278406473168"
|
||||||
"2041565926728632933630474670123316852983422152744517260835859654" //# 03: ok
|
"2041565926728632933630474670123316852983422152744517260835859654"
|
||||||
"5663192828352447877877998943107797838336991592885945552137141811" //# 03: ok
|
"5663192828352447877877998943107797838336991592885945552137141811"
|
||||||
"2845825114558431922307989750439508685941245723089173894616936837" //# 03: ok
|
"2845825114558431922307989750439508685941245723089173894616936837"
|
||||||
"2321191373658977977723286698840356390251044443035457396733706583" //# 03: ok
|
"2321191373658977977723286698840356390251044443035457396733706583"
|
||||||
"9810554204566938246584137476071559811765738776267476659123871999" //# 03: ok
|
"9810554204566938246584137476071559811765738776267476659123871999"
|
||||||
"3190400631733470900301279018817520344719025002806127777791679839" //# 03: ok
|
"3190400631733470900301279018817520344719025002806127777791679839"
|
||||||
"1090578584006464715943810511489154282775041174682194133952466682" //# 03: ok
|
"1090578584006464715943810511489154282775041174682194133952466682"
|
||||||
"5034313061815878293790042053923750720833666932415800027583911188" //# 03: ok
|
"5034313061815878293790042053923750720833666932415800027583911188"
|
||||||
"54188641513168478436313080237596295773983001708984375", //# 03: ok
|
"54188641513168478436313080237596295773983001708984375",
|
||||||
2.2250738585072024e-308); //# 03: ok
|
2.2250738585072024e-308);
|
||||||
testParse( //# 03: ok
|
testParse(
|
||||||
"0.00000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0.00000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000022250738585" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000022250738585"
|
||||||
"0720212418870147920222032907240528279439056398987153733445293826" //# 03: ok
|
"0720212418870147920222032907240528279439056398987153733445293826"
|
||||||
"2841914532254970474258308397286505854246486958895941513684460970" //# 03: ok
|
"2841914532254970474258308397286505854246486958895941513684460970"
|
||||||
"4068152972799584860088646519366819731179394084384097665233499900" //# 03: ok
|
"4068152972799584860088646519366819731179394084384097665233499900"
|
||||||
"0755861120300770354269606853101364036287721693053184667205738737" //# 03: ok
|
"0755861120300770354269606853101364036287721693053184667205738737"
|
||||||
"5949174050909314222165141860993427546865066465011668770360303425" //# 03: ok
|
"5949174050909314222165141860993427546865066465011668770360303425"
|
||||||
"3994515112524200040764624453870560455886026635830913894056826102" //# 03: ok
|
"3994515112524200040764624453870560455886026635830913894056826102"
|
||||||
"6558396263994546949554344059607291509746117227014454385071719673" //# 03: ok
|
"6558396263994546949554344059607291509746117227014454385071719673"
|
||||||
"8131016897819660470375391476074607837156312396985947983896498558" //# 03: ok
|
"8131016897819660470375391476074607837156312396985947983896498558"
|
||||||
"1739504563131807656934782164684779819754568515974931805299288032" //# 03: ok
|
"1739504563131807656934782164684779819754568515974931805299288032"
|
||||||
"9467318908203746468430727830398768346578595574013759265666391011" //# 03: ok
|
"9467318908203746468430727830398768346578595574013759265666391011"
|
||||||
"5651945906921898169113014030529134467663458535415036957197921783" //# 03: ok
|
"5651945906921898169113014030529134467663458535415036957197921783"
|
||||||
"4550533979841101562169154890806946368370134291387467238490102415" //# 03: ok
|
"4550533979841101562169154890806946368370134291387467238490102415"
|
||||||
"1863156959008792461225924284245693964036455110947393215135657241" //# 03: ok
|
"1863156959008792461225924284245693964036455110947393215135657241"
|
||||||
"099571834741510656385798938572406768798828125", //# 03: ok
|
"099571834741510656385798938572406768798828125",
|
||||||
2.2250738585072024e-308); //# 03: ok
|
2.2250738585072024e-308);
|
||||||
testParse(
|
testParse(
|
||||||
"0.00000000000000000000000000000000000000000000000000000000000000"
|
"0.00000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000"
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
|
@ -895,26 +893,26 @@ void main() {
|
||||||
"8909645359318233784351199339157645340492308605462312698364257812"
|
"8909645359318233784351199339157645340492308605462312698364257812"
|
||||||
"5",
|
"5",
|
||||||
1.0020841800044864e-292);
|
1.0020841800044864e-292);
|
||||||
testParse( //# 03: ok
|
testParse(
|
||||||
"0.00000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0.00000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000100208418000448650025174695" //# 03: ok
|
"0000000000000000000000000000000000000100208418000448650025174695"
|
||||||
"1035150178458809017822159251011531515138151971877843746285762442" //# 03: ok
|
"1035150178458809017822159251011531515138151971877843746285762442"
|
||||||
"8545112214057342269294258292239779301929355259416640067909319649" //# 03: ok
|
"8545112214057342269294258292239779301929355259416640067909319649"
|
||||||
"7365336576866690449490575153391617964764463657240626936945707789" //# 03: ok
|
"7365336576866690449490575153391617964764463657240626936945707789"
|
||||||
"0322677840073401894046998179185686691822730198820493814317137229" //# 03: ok
|
"0322677840073401894046998179185686691822730198820493814317137229"
|
||||||
"5822164306994752582767555905533610628109411569344063803273395309" //# 03: ok
|
"5822164306994752582767555905533610628109411569344063803273395309"
|
||||||
"4016739578124191615155910675820643598048478728683293279406596985" //# 03: ok
|
"4016739578124191615155910675820643598048478728683293279406596985"
|
||||||
"3795142966229399885915374796852136102192598807080147602085351627" //# 03: ok
|
"3795142966229399885915374796852136102192598807080147602085351627"
|
||||||
"7462738186176388661491270541112149644974737467220377156516124492" //# 03: ok
|
"7462738186176388661491270541112149644974737467220377156516124492"
|
||||||
"5297987696655648150350049348782647584189423429523649017245633309" //# 03: ok
|
"5297987696655648150350049348782647584189423429523649017245633309"
|
||||||
"0650703736050481424426844685046761507858235356421727632283550512" //# 03: ok
|
"0650703736050481424426844685046761507858235356421727632283550512"
|
||||||
"9294184882356332903145058239310065886479547694117011957754993659" //# 03: ok
|
"9294184882356332903145058239310065886479547694117011957754993659"
|
||||||
"5152049332041520812604025151794328168042160636342216519487980314" //# 03: ok
|
"5152049332041520812604025151794328168042160636342216519487980314"
|
||||||
"421878240614097350935640662328296457417309284210205078125", //# 03: ok
|
"421878240614097350935640662328296457417309284210205078125",
|
||||||
1.0020841800044866e-292); //# 03: ok
|
1.0020841800044866e-292);
|
||||||
testParse(
|
testParse(
|
||||||
"0.00000000000000000000000000000000000000000000000000000000000000"
|
"0.00000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000"
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
|
@ -973,45 +971,45 @@ void main() {
|
||||||
"4847950667958479187395974848205671831957839363657783480512019685"
|
"4847950667958479187395974848205671831957839363657783480512019685"
|
||||||
"578121759385902649064359337671703542582690715789794921875",
|
"578121759385902649064359337671703542582690715789794921875",
|
||||||
2.0041683600089726e-292);
|
2.0041683600089726e-292);
|
||||||
testParse( //# 03: ok
|
testParse(
|
||||||
"0.00000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0.00000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000200416836000897266674241512" //# 03: ok
|
"0000000000000000000000000000000000000200416836000897266674241512"
|
||||||
"5990092893382710435783708701744713907322363070003179054747514262" //# 03: ok
|
"5990092893382710435783708701744713907322363070003179054747514262"
|
||||||
"7385611700512865061525449421701203817286652851291627374287240329" //# 03: ok
|
"7385611700512865061525449421701203817286652851291627374287240329"
|
||||||
"3753705169156289950978164746871212513772283206234057202629821353" //# 03: ok
|
"3753705169156289950978164746871212513772283206234057202629821353"
|
||||||
"8809538439162226010550634208659737749820025430842192660178060615" //# 03: ok
|
"8809538439162226010550634208659737749820025430842192660178060615"
|
||||||
"3474267718174236120090795958487048484027109406716660005865875254" //# 03: ok
|
"3474267718174236120090795958487048484027109406716660005865875254"
|
||||||
"7540730218997620056025234843183240653494745917236268600971966054" //# 03: ok
|
"7540730218997620056025234843183240653494745917236268600971966054"
|
||||||
"2572750817920844689872038240532666937066187074066929436725783508" //# 03: ok
|
"2572750817920844689872038240532666937066187074066929436725783508"
|
||||||
"0513647350599865639683590212819431367049178252060735656411044144" //# 03: ok
|
"0513647350599865639683590212819431367049178252060735656411044144"
|
||||||
"5314088186163138416702979387974756763836546863081940712096908853" //# 03: ok
|
"5314088186163138416702979387974756763836546863081940712096908853"
|
||||||
"9929165937080868658779320353585122361868059050079309936626251244" //# 03: ok
|
"9929165937080868658779320353585122361868059050079309936626251244"
|
||||||
"0765647609431766215648800660842354659507691394537687301635742187" //# 03: ok
|
"0765647609431766215648800660842354659507691394537687301635742187"
|
||||||
"5", //# 03: ok
|
"5",
|
||||||
2.004168360008973e-292); //# 03: ok
|
2.004168360008973e-292);
|
||||||
testParse( //# 03: ok
|
testParse(
|
||||||
"0.00000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0.00000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok
|
"0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"0000000000000000000000000000000000000200416836000897266674241512" //# 03: ok
|
"0000000000000000000000000000000000000200416836000897266674241512"
|
||||||
"5990092893382710435783708785442689934124446215379877007119186963" //# 03: ok
|
"5990092893382710435783708785442689934124446215379877007119186963"
|
||||||
"1799271173601405540673717580039876412295823431198128133887844732" //# 03: ok
|
"1799271173601405540673717580039876412295823431198128133887844732"
|
||||||
"7822096271111944266498822575337206743053529154538278267721206728" //# 03: ok
|
"7822096271111944266498822575337206743053529154538278267721206728"
|
||||||
"1206759279588886755511816487266193645578706075743945771432529989" //# 03: ok
|
"1206759279588886755511816487266193645578706075743945771432529989"
|
||||||
"5627720577353214542977288069464672781437627568914207256313896083" //# 03: ok
|
"5627720577353214542977288069464672781437627568914207256313896083"
|
||||||
"6647266336088483105727658239269018534852601546443784653776612265" //# 03: ok
|
"6647266336088483105727658239269018534852601546443784653776612265"
|
||||||
"4362171708319597782738064157144965045964873355636409438294693959" //# 03: ok
|
"4362171708319597782738064157144965045964873355636409438294693959"
|
||||||
"3883447613213167389211587415988230219943616159642947883454256631" //# 03: ok
|
"3883447613213167389211587415988230219943616159642947883454256631"
|
||||||
"7129850578881555219447792913718868827972321214300345663373246010" //# 03: ok
|
"7129850578881555219447792913718868827972321214300345663373246010"
|
||||||
"5887233720340859229642766731751409169335306833113418201122555553" //# 03: ok
|
"5887233720340859229642766731751409169335306833113418201122555553"
|
||||||
"1150187132469865334442659560994775205494930483192386561026478034" //# 03: ok
|
"1150187132469865334442659560994775205494930483192386561026478034"
|
||||||
"5152049332041520812604025151794328168042160636342216519487980314" //# 03: ok
|
"5152049332041520812604025151794328168042160636342216519487980314"
|
||||||
"421878240614097350935640662328296457417309284210205078125", //# 03: ok
|
"421878240614097350935640662328296457417309284210205078125",
|
||||||
2.004168360008973e-292); //# 03: ok
|
2.004168360008973e-292);
|
||||||
testParse("0.99999999999999988897769753748434595763683319091796875",
|
testParse("0.99999999999999988897769753748434595763683319091796875",
|
||||||
0.9999999999999999);
|
0.9999999999999999);
|
||||||
testParse(
|
testParse(
|
||||||
|
@ -1024,14 +1022,14 @@ void main() {
|
||||||
"4809443029054117700758095643512548748358614094344726684993771234"
|
"4809443029054117700758095643512548748358614094344726684993771234"
|
||||||
"576088145773464788135242997668683528900146484375",
|
"576088145773464788135242997668683528900146484375",
|
||||||
0.9999999999999999);
|
0.9999999999999999);
|
||||||
testParse( //# 03: ok
|
testParse(
|
||||||
"0.999999999999999944488848768742172978818416595458984375", //# 03: ok
|
"0.999999999999999944488848768742172978818416595458984375",
|
||||||
1.0); //# 03: ok
|
1.0);
|
||||||
testParse( //# 03: ok
|
testParse(
|
||||||
"0.99999999999999994448884876874217297881841659545898441676194859" //# 03: ok
|
"0.99999999999999994448884876874217297881841659545898441676194859"
|
||||||
"5190556970945882299241904356487451251641385905655273315006228765" //# 03: ok
|
"5190556970945882299241904356487451251641385905655273315006228765"
|
||||||
"423911854226535211864757002331316471099853515625", //# 03: ok
|
"423911854226535211864757002331316471099853515625",
|
||||||
1.0); //# 03: ok
|
1.0);
|
||||||
testParse("0.499999999999999944488848768742172978818416595458984375",
|
testParse("0.499999999999999944488848768742172978818416595458984375",
|
||||||
0.49999999999999994);
|
0.49999999999999994);
|
||||||
testParse(
|
testParse(
|
||||||
|
@ -1044,14 +1042,14 @@ void main() {
|
||||||
"2404721514527058850379047821756274374179307047172363342496885617"
|
"2404721514527058850379047821756274374179307047172363342496885617"
|
||||||
"2880440728867323940676214988343417644500732421875",
|
"2880440728867323940676214988343417644500732421875",
|
||||||
0.49999999999999994);
|
0.49999999999999994);
|
||||||
testParse( //# 03: ok
|
testParse(
|
||||||
"0.4999999999999999722444243843710864894092082977294921875", //# 03: ok
|
"0.4999999999999999722444243843710864894092082977294921875",
|
||||||
0.5); //# 03: ok
|
0.5);
|
||||||
testParse( //# 03: ok
|
testParse(
|
||||||
"0.49999999999999997224442438437108648940920829772949220838097429" //# 03: ok
|
"0.49999999999999997224442438437108648940920829772949220838097429"
|
||||||
"7595278485472941149620952178243725625820692952827636657503114382" //# 03: ok
|
"7595278485472941149620952178243725625820692952827636657503114382"
|
||||||
"7119559271132676059323785011656582355499267578125", //# 03: ok
|
"7119559271132676059323785011656582355499267578125",
|
||||||
0.5); //# 03: ok
|
0.5);
|
||||||
testParse("1.9999999999999997779553950749686919152736663818359375",
|
testParse("1.9999999999999997779553950749686919152736663818359375",
|
||||||
1.9999999999999998);
|
1.9999999999999998);
|
||||||
testParse(
|
testParse(
|
||||||
|
@ -1064,14 +1062,14 @@ void main() {
|
||||||
"9618886058108235401516191287025097496717228188689453369987542469"
|
"9618886058108235401516191287025097496717228188689453369987542469"
|
||||||
"15217629154692957627048599533736705780029296875",
|
"15217629154692957627048599533736705780029296875",
|
||||||
1.9999999999999998);
|
1.9999999999999998);
|
||||||
testParse( //# 03: ok
|
testParse(
|
||||||
"1.99999999999999988897769753748434595763683319091796875", //# 03: ok
|
"1.99999999999999988897769753748434595763683319091796875",
|
||||||
2.0); //# 03: ok
|
2.0);
|
||||||
testParse( //# 03: ok
|
testParse(
|
||||||
"1.99999999999999988897769753748434595763683319091796883352389719" //# 03: ok
|
"1.99999999999999988897769753748434595763683319091796883352389719"
|
||||||
"0381113941891764598483808712974902503282771811310546630012457530" //# 03: ok
|
"0381113941891764598483808712974902503282771811310546630012457530"
|
||||||
"84782370845307042372951400466263294219970703125", //# 03: ok
|
"84782370845307042372951400466263294219970703125",
|
||||||
2.0); //# 03: ok
|
2.0);
|
||||||
testParse("4503599627370495.5", 4503599627370495.5);
|
testParse("4503599627370495.5", 4503599627370495.5);
|
||||||
testParse(
|
testParse(
|
||||||
"4503599627370495.50000000000000000000000000000000000018807909613"
|
"4503599627370495.50000000000000000000000000000000000018807909613"
|
||||||
|
@ -1165,13 +1163,13 @@ void main() {
|
||||||
testParse("1e-22", 1e-22);
|
testParse("1e-22", 1e-22);
|
||||||
testParse("1e-23", 1e-23);
|
testParse("1e-23", 1e-23);
|
||||||
|
|
||||||
testParseWhitespace("1", 1.0); //# 04: ok
|
testParseWhitespace("1", 1.0);
|
||||||
testParseWhitespace("1.0", 1.0); //# 04: ok
|
testParseWhitespace("1.0", 1.0);
|
||||||
testParseWhitespace("1e1", 10.0); //# 04: ok
|
testParseWhitespace("1e1", 10.0);
|
||||||
testParseWhitespace(".1e1", 1.0); //# 04: ok
|
testParseWhitespace(".1e1", 1.0);
|
||||||
testParseWhitespace("1.e1", 10.0); //# 04: ok
|
testParseWhitespace("1.e1", 10.0);
|
||||||
testParseWhitespace("1e+1", 10.0); //# 04: ok
|
testParseWhitespace("1e+1", 10.0);
|
||||||
testParseWhitespace("1e-1", 0.1); //# 04: ok
|
testParseWhitespace("1e-1", 0.1);
|
||||||
|
|
||||||
// Negative tests - things not to allow.
|
// Negative tests - things not to allow.
|
||||||
|
|
||||||
|
|
1209
tests/corelib_2/double_try_parse_test.dart
Normal file
1209
tests/corelib_2/double_try_parse_test.dart
Normal file
File diff suppressed because it is too large
Load diff
129
tests/corelib_2/int_try_parse_test.dart
Normal file
129
tests/corelib_2/int_try_parse_test.dart
Normal file
|
@ -0,0 +1,129 @@
|
||||||
|
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||||
|
// for details. All rights reserved. Use of this source code is governed by a
|
||||||
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
import "package:expect/expect.dart";
|
||||||
|
import "dart:math" show pow, log;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
const String oneByteWhiteSpace = "\x09\x0a\x0b\x0c\x0d\x20\xa0";
|
||||||
|
const String whiteSpace = "$oneByteWhiteSpace\u1680"
|
||||||
|
"\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a"
|
||||||
|
"\u2028\u2029\u202f\u205f\u3000\ufeff";
|
||||||
|
|
||||||
|
var digits = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||||
|
var zeros = "0" * 64;
|
||||||
|
|
||||||
|
for (int i = 0; i < whiteSpace.length; i++) {
|
||||||
|
var ws = whiteSpace[i];
|
||||||
|
Expect.equals(0, int.parse("${ws}0${ws}", radix: 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
void testParse(int result, String radixString, int radix) {
|
||||||
|
var m = "$radixString/$radix->$result";
|
||||||
|
Expect.equals(
|
||||||
|
result, int.tryParse(radixString.toLowerCase(), radix: radix), m);
|
||||||
|
Expect.equals(
|
||||||
|
result, int.tryParse(radixString.toUpperCase(), radix: radix), m);
|
||||||
|
Expect.equals(result, int.tryParse(" $radixString", radix: radix), m);
|
||||||
|
Expect.equals(result, int.tryParse("$radixString ", radix: radix), m);
|
||||||
|
Expect.equals(result, int.tryParse(" $radixString ", radix: radix), m);
|
||||||
|
Expect.equals(result, int.tryParse("+$radixString", radix: radix), m);
|
||||||
|
Expect.equals(result, int.tryParse(" +$radixString", radix: radix), m);
|
||||||
|
Expect.equals(result, int.tryParse("+$radixString ", radix: radix), m);
|
||||||
|
Expect.equals(result, int.tryParse(" +$radixString ", radix: radix), m);
|
||||||
|
Expect.equals(-result, int.tryParse("-$radixString", radix: radix), m);
|
||||||
|
Expect.equals(-result, int.tryParse(" -$radixString", radix: radix), m);
|
||||||
|
Expect.equals(-result, int.tryParse("-$radixString ", radix: radix), m);
|
||||||
|
Expect.equals(-result, int.tryParse(" -$radixString ", radix: radix), m);
|
||||||
|
Expect.equals(
|
||||||
|
result,
|
||||||
|
int.tryParse("$oneByteWhiteSpace$radixString$oneByteWhiteSpace",
|
||||||
|
radix: radix),
|
||||||
|
m);
|
||||||
|
Expect.equals(
|
||||||
|
-result,
|
||||||
|
int.tryParse("$oneByteWhiteSpace-$radixString$oneByteWhiteSpace",
|
||||||
|
radix: radix),
|
||||||
|
m);
|
||||||
|
Expect.equals(result,
|
||||||
|
int.tryParse("$whiteSpace$radixString$whiteSpace", radix: radix), m);
|
||||||
|
Expect.equals(-result,
|
||||||
|
int.tryParse("$whiteSpace-$radixString$whiteSpace", radix: radix), m);
|
||||||
|
|
||||||
|
Expect.equals(result, int.tryParse("$zeros$radixString", radix: radix), m);
|
||||||
|
Expect.equals(result, int.tryParse("+$zeros$radixString", radix: radix), m);
|
||||||
|
Expect.equals(
|
||||||
|
-result, int.tryParse("-$zeros$radixString", radix: radix), m);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int r = 2; r <= 36; r++) {
|
||||||
|
for (int i = 0; i <= r * r; i++) {
|
||||||
|
String radixString = i.toRadixString(r);
|
||||||
|
testParse(i, radixString, r);
|
||||||
|
}
|
||||||
|
for (var v in [
|
||||||
|
0,
|
||||||
|
0x10000,
|
||||||
|
0x7FFFFFFF,
|
||||||
|
0x80000000,
|
||||||
|
0xFFFFFFFF,
|
||||||
|
0x100000000,
|
||||||
|
0x7FFFFFFFFFFFF8,
|
||||||
|
]) {
|
||||||
|
var string = v.toRadixString(r);
|
||||||
|
Expect.equals(v, int.tryParse(string, radix: r));
|
||||||
|
if (v > 0) {
|
||||||
|
Expect.equals(-v, int.tryParse("-$string", radix: r));
|
||||||
|
if (r == 16) {
|
||||||
|
Expect.equals(v, int.tryParse("0x$string"));
|
||||||
|
Expect.equals(v, int.tryParse("0X$string"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow both upper- and lower-case letters.
|
||||||
|
Expect.equals(0xABCD, int.tryParse("ABCD", radix: 16));
|
||||||
|
Expect.equals(0xABCD, int.tryParse("abcd", radix: 16));
|
||||||
|
Expect.equals(15628859, int.tryParse("09azAZ", radix: 36));
|
||||||
|
// Big numbers (representable as both Int64 and double).
|
||||||
|
Expect.equals(9223372036854774784, int.tryParse("9223372036854774784"));
|
||||||
|
Expect.equals(-9223372036854775808, int.tryParse("-9223372036854775808"));
|
||||||
|
// Allow whitespace before and after the number.
|
||||||
|
Expect.equals(1, int.tryParse(" 1", radix: 2));
|
||||||
|
Expect.equals(1, int.tryParse("1 ", radix: 2));
|
||||||
|
Expect.equals(1, int.tryParse(" 1 ", radix: 2));
|
||||||
|
Expect.equals(1, int.tryParse("\n1", radix: 2));
|
||||||
|
Expect.equals(1, int.tryParse("1\n", radix: 2));
|
||||||
|
Expect.equals(1, int.tryParse("\n1\n", radix: 2));
|
||||||
|
Expect.equals(1, int.tryParse("+1", radix: 2));
|
||||||
|
|
||||||
|
void testFails(String source, int radix) {
|
||||||
|
Expect.isNull(int.tryParse(source, radix: radix));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 2; i < 36; i++) {
|
||||||
|
var char = i.toRadixString(36);
|
||||||
|
testFails(char.toLowerCase(), i);
|
||||||
|
testFails(char.toUpperCase(), i);
|
||||||
|
}
|
||||||
|
testFails("", 2);
|
||||||
|
testFails("+ 1", 2); // No space between sign and digits.
|
||||||
|
testFails("- 1", 2); // No space between sign and digits.
|
||||||
|
testFails("0x", null);
|
||||||
|
for (int i = 2; i <= 33; i++) {
|
||||||
|
// No 0x specially allowed.
|
||||||
|
// At radix 34 and above, "x" is a valid digit.
|
||||||
|
testFails("0x10", i);
|
||||||
|
}
|
||||||
|
int digitX = 33;
|
||||||
|
Expect.equals(((digitX * 34) + 1) * 34, int.tryParse("0x10", radix: 34));
|
||||||
|
Expect.equals(((digitX * 35) + 1) * 35, int.tryParse("0x10", radix: 35));
|
||||||
|
|
||||||
|
// Radix must be in the range 2 .. 36.
|
||||||
|
Expect.throwsArgumentError(() => int.tryParse("0", radix: -1));
|
||||||
|
Expect.throwsArgumentError(() => int.tryParse("0", radix: 0));
|
||||||
|
Expect.throwsArgumentError(() => int.tryParse("0", radix: -1));
|
||||||
|
Expect.throwsArgumentError(() => int.tryParse("0", radix: 37));
|
||||||
|
}
|
222
tests/corelib_2/num_try_parse_test.dart
Normal file
222
tests/corelib_2/num_try_parse_test.dart
Normal file
|
@ -0,0 +1,222 @@
|
||||||
|
// Copyright (c) 2013 the Dart project authors. Please see the AUTHORS file
|
||||||
|
// for details. All rights reserved. Use of this source code is governed by a
|
||||||
|
// BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
import "package:expect/expect.dart";
|
||||||
|
|
||||||
|
const whiteSpace = const [
|
||||||
|
"",
|
||||||
|
"\x09",
|
||||||
|
"\x0a",
|
||||||
|
"\x0b",
|
||||||
|
"\x0c",
|
||||||
|
"\x0d",
|
||||||
|
"\xa0",
|
||||||
|
"\u1680",
|
||||||
|
"\u2000",
|
||||||
|
"\u2001",
|
||||||
|
"\u2002",
|
||||||
|
"\u2003",
|
||||||
|
"\u2004",
|
||||||
|
"\u2005",
|
||||||
|
"\u2006",
|
||||||
|
"\u2007",
|
||||||
|
"\u2008",
|
||||||
|
"\u2009",
|
||||||
|
"\u200a",
|
||||||
|
"\u2028",
|
||||||
|
"\u2029",
|
||||||
|
"\u202f",
|
||||||
|
"\u205f",
|
||||||
|
"\u3000",
|
||||||
|
"\uFEFF"
|
||||||
|
];
|
||||||
|
|
||||||
|
void expectNumEquals(num expect, num actual, String message) {
|
||||||
|
if (expect is double && expect.isNaN) {
|
||||||
|
Expect.isTrue(actual is double && actual.isNaN, "isNaN: $message");
|
||||||
|
} else {
|
||||||
|
Expect.identical(expect, actual, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test source surrounded by any combination of whitespace.
|
||||||
|
void testParseAllWhitespace(String source, num result) {
|
||||||
|
for (String ws1 in whiteSpace) {
|
||||||
|
for (String ws2 in whiteSpace) {
|
||||||
|
String padded = "$ws1$source$ws2";
|
||||||
|
// Use Expect.identical because it also handles NaN and 0.0/-0.0.
|
||||||
|
// Except on dart2js: http://dartbug.com/11551
|
||||||
|
expectNumEquals(result, num.parse(padded), "parse '$padded'");
|
||||||
|
padded = "$ws1$ws2$source";
|
||||||
|
expectNumEquals(result, num.parse(padded), "parse '$padded'");
|
||||||
|
padded = "$source$ws1$ws2";
|
||||||
|
expectNumEquals(result, num.parse(padded), "parse '$padded'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test source and -source surrounded by any combination of whitespace.
|
||||||
|
void testParseWhitespace(String source, num result) {
|
||||||
|
assert(result >= 0);
|
||||||
|
testParseAllWhitespace(source, result);
|
||||||
|
testParseAllWhitespace("-$source", -result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void testParse(String source, num result) {
|
||||||
|
expectNumEquals(result, num.tryParse(source), "parse '$source'");
|
||||||
|
expectNumEquals(result, num.tryParse(" $source"), "parse ' $source'");
|
||||||
|
expectNumEquals(result, num.tryParse("$source "), "parse '$source '");
|
||||||
|
expectNumEquals(result, num.tryParse(" $source "), "parse ' $source '");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test parsing an integer in decimal or hex format, with or without signs.
|
||||||
|
void testInt(int value) {
|
||||||
|
testParse("$value", value);
|
||||||
|
testParse("+$value", value);
|
||||||
|
testParse("-$value", -value);
|
||||||
|
var hex = "0x${value.toRadixString(16)}";
|
||||||
|
var lchex = hex.toLowerCase();
|
||||||
|
testParse(lchex, value);
|
||||||
|
testParse("+$lchex", value);
|
||||||
|
testParse("-$lchex", -value);
|
||||||
|
var uchex = hex.toUpperCase();
|
||||||
|
testParse(uchex, value);
|
||||||
|
testParse("+$uchex", value);
|
||||||
|
testParse("-$uchex", -value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test parsing an integer, and the integers just around it.
|
||||||
|
void testIntAround(int value) {
|
||||||
|
testInt(value - 1);
|
||||||
|
testInt(value);
|
||||||
|
testInt(value + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void testDouble(double value) {
|
||||||
|
testParse("$value", value);
|
||||||
|
testParse("+$value", value);
|
||||||
|
testParse("-$value", -value);
|
||||||
|
if (value.isFinite) {
|
||||||
|
String exp = value.toStringAsExponential();
|
||||||
|
String lcexp = exp.toLowerCase();
|
||||||
|
testParse(lcexp, value);
|
||||||
|
testParse("+$lcexp", value);
|
||||||
|
testParse("-$lcexp", -value);
|
||||||
|
String ucexp = exp.toUpperCase();
|
||||||
|
testParse(ucexp, value);
|
||||||
|
testParse("+$ucexp", value);
|
||||||
|
testParse("-$ucexp", -value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void testFail(String source) {
|
||||||
|
Expect.isNull(num.tryParse(source));
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testInt(0);
|
||||||
|
testInt(1);
|
||||||
|
testInt(9);
|
||||||
|
testInt(10);
|
||||||
|
testInt(99);
|
||||||
|
testInt(100);
|
||||||
|
testIntAround(256);
|
||||||
|
testIntAround(0x80000000); // 2^31
|
||||||
|
testIntAround(0x100000000); // 2^32
|
||||||
|
testIntAround(0x10000000000000); // 2^52
|
||||||
|
testIntAround(0x1FFFFFFFFFFFFF); // 2^53 - 1
|
||||||
|
|
||||||
|
testDouble(0.0);
|
||||||
|
testDouble(5e-324);
|
||||||
|
testDouble(2.225073858507201e-308);
|
||||||
|
testDouble(2.2250738585072014e-308);
|
||||||
|
testDouble(0.49999999999999994);
|
||||||
|
testDouble(0.5);
|
||||||
|
testDouble(0.50000000000000006);
|
||||||
|
testDouble(0.9999999999999999);
|
||||||
|
testDouble(1.0);
|
||||||
|
testDouble(1.0000000000000002);
|
||||||
|
testDouble(4294967295.0);
|
||||||
|
testDouble(4294967296.0);
|
||||||
|
testDouble(4503599627370495.5);
|
||||||
|
testDouble(4503599627370497.0);
|
||||||
|
testDouble(9007199254740991.0);
|
||||||
|
testDouble(9007199254740992.0);
|
||||||
|
testDouble(1.7976931348623157e+308);
|
||||||
|
testDouble(double.infinity);
|
||||||
|
testDouble(double.nan);
|
||||||
|
|
||||||
|
// Strings that cannot occur from toString of a number.
|
||||||
|
testParse("000000000000", 0);
|
||||||
|
testParse("000000000001", 1);
|
||||||
|
testParse("000000000000.0000000000000", 0.0);
|
||||||
|
testParse("000000000001.0000000000000", 1.0);
|
||||||
|
testParse("0x0000000000", 0);
|
||||||
|
testParse("0e0", 0.0);
|
||||||
|
testParse("0e+0", 0.0);
|
||||||
|
testParse("0e-0", 0.0);
|
||||||
|
testParse("-0e0", -0.0);
|
||||||
|
testParse("-0e+0", -0.0);
|
||||||
|
testParse("-0e-0", -0.0);
|
||||||
|
testParse("1e0", 1.0);
|
||||||
|
testParse("1e+0", 1.0);
|
||||||
|
testParse("1e-0", 1.0);
|
||||||
|
testParse("-1e0", -1.0);
|
||||||
|
testParse("-1e+0", -1.0);
|
||||||
|
testParse("-1e-0", -1.0);
|
||||||
|
testParse("1.", 1.0);
|
||||||
|
testParse(".1", 0.1);
|
||||||
|
testParse("1.e1", 10.0);
|
||||||
|
testParse(".1e1", 1.0);
|
||||||
|
|
||||||
|
testParseWhitespace("0x1", 1);
|
||||||
|
testParseWhitespace("1", 1);
|
||||||
|
testParseWhitespace("1.0", 1.0);
|
||||||
|
testParseWhitespace("1e1", 10.0);
|
||||||
|
testParseWhitespace(".1e1", 1.0);
|
||||||
|
testParseWhitespace("1.e1", 10.0);
|
||||||
|
testParseWhitespace("1e+1", 10.0);
|
||||||
|
testParseWhitespace("1e-1", 0.1);
|
||||||
|
|
||||||
|
// Negative tests - things not to allow.
|
||||||
|
|
||||||
|
// Spaces inside the numeral.
|
||||||
|
testFail("- 1");
|
||||||
|
testFail("+ 1");
|
||||||
|
testFail("2 2");
|
||||||
|
testFail("0x 42");
|
||||||
|
testFail("1 .");
|
||||||
|
testFail(". 1");
|
||||||
|
testFail("1e 2");
|
||||||
|
testFail("1 e2");
|
||||||
|
// Invalid characters.
|
||||||
|
testFail("0x1H");
|
||||||
|
testFail("12H");
|
||||||
|
testFail("1x2");
|
||||||
|
testFail("00x2");
|
||||||
|
testFail("0x2.2");
|
||||||
|
// Empty hex number.
|
||||||
|
testFail("0x");
|
||||||
|
testFail("-0x");
|
||||||
|
testFail("+0x");
|
||||||
|
// Double exponent without value.
|
||||||
|
testFail(".e1");
|
||||||
|
testFail("e1");
|
||||||
|
testFail("e+1");
|
||||||
|
testFail("e-1");
|
||||||
|
testFail("-e1");
|
||||||
|
testFail("-e+1");
|
||||||
|
testFail("-e-1");
|
||||||
|
// Incorrect ways to write NaN/Infinity.
|
||||||
|
testFail("infinity");
|
||||||
|
testFail("INFINITY");
|
||||||
|
testFail("1.#INF");
|
||||||
|
testFail("inf");
|
||||||
|
testFail("nan");
|
||||||
|
testFail("NAN");
|
||||||
|
testFail("1.#IND");
|
||||||
|
testFail("indef");
|
||||||
|
testFail("qnan");
|
||||||
|
testFail("snan");
|
||||||
|
}
|
Loading…
Reference in a new issue