Add tests for implicit conversion of integer literals to double values in a double context.
Planned for Dart 2.1. Change-Id: I0cc7c6f4ea654cbb66b1542b0bc6e0c32728be12 Reviewed-on: https://dart-review.googlesource.com/47880 Commit-Queue: Lasse R.H. Nielsen <lrn@google.com> Reviewed-by: Erik Ernst <eernst@google.com> Reviewed-by: Leaf Petersen <leafp@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
9ab03ce3a3
commit
d6bec62322
@@ -3874,10 +3874,16 @@ It has the numeric integer value of the decimal numeral.
|
||||
An {\em integer literal} is either a hexadecimal integer literal or a decimal integer literal.
|
||||
|
||||
\LMHash{}
|
||||
An integer literal has static type \code{int},
|
||||
unless the surrounding static context type is a type
|
||||
which \code{int} is not assignable to, and \code{double} is.
|
||||
In that case the static type of the integer literal is \code{double}.
|
||||
Let $l$ be an integer literal that is not the operand
|
||||
of by a unary minus operator,
|
||||
and let $T$ be the static context type of $l$.
|
||||
If \code{double} is assignable to $T$ and \code{int} is not assignable to $T$,
|
||||
then the static type of $l$ is \code{double};
|
||||
otherwise the static type of $l$ is \code{int}.
|
||||
\commentary{
|
||||
This means that an integer literal denotes a \code{double}
|
||||
when it would satisfy the type requirement, and an \code{int} would not. Otherwise it is an \code{int}, even in situations where that is an error.
|
||||
}
|
||||
|
||||
\LMHash{}
|
||||
A numeric literal that is not an integer literal is a {\em double literal}.
|
||||
@@ -3885,19 +3891,20 @@ A numeric literal that is not an integer literal is a {\em double literal}.
|
||||
The static type of a double literal is \code{double}.
|
||||
|
||||
\LMHash{}
|
||||
If the \code{int} class is implemented as signed 64-bit two's complement integers,
|
||||
and a hexadecimal integer literal with static type \code{int}
|
||||
and numeric value $i \ge{} 2^{63}$ is not prefixed by a unary minus operator,
|
||||
then it is a compile-time error if $i \ge{} 2^{64}$, and otherwise
|
||||
the hexadecimal integer literal evaluates to an instance of the \code{int} class
|
||||
representing the value $i - 2^{64}$.
|
||||
|
||||
\LMHash{}
|
||||
Otherwise an integer literal with static type \code{int}
|
||||
that is not prefixed by a unary minus operator,
|
||||
evaluates to an instance of the \code{int} class representing the integer value $i$,
|
||||
and it is a compile-time error if the integer $i$ cannot be represented exactly
|
||||
by an instance of \code{int}.
|
||||
If $l$ is an integer literal with numeric value $i$ and static type \code{int},
|
||||
and $l$ is not the operand of a unary minus operator,
|
||||
then evaluation of $l$ proceeds as follows:
|
||||
\begin{itemize}
|
||||
\item{} If $l$ is a hexadecimal integer literal,
|
||||
$2^{63} \le{} i \lt{} 2^{64}$ and the \code{int} class is implemented as
|
||||
signed 64-bit two's complement integers,
|
||||
then $l$ evaluates to an instance of the \code{int} class
|
||||
representing the numeric value $i - 2^{64}$,
|
||||
\item{} Otherwise $l$ evaluates to an instance of the \code{int} class
|
||||
representing the numeric value $i$.
|
||||
It is a compile-time error if the integer $i$ cannot be represented
|
||||
exactly by an instance of \code{int}.
|
||||
\end{itemize}
|
||||
|
||||
\commentary{
|
||||
Integers in Dart are designed to be implemented as
|
||||
@@ -3918,7 +3925,7 @@ as specified by the IEEE 754 standard.
|
||||
An integer literal with static type \code{double} and numeric value $i$
|
||||
evaluates to an instance of the \code{double} class representing
|
||||
the value $i$. It is a compile-time error if the value $i$ cannot be
|
||||
represented {\em precisely} by the an instace of \code{double}.
|
||||
represented {\em precisely} by the an instance of \code{double}.
|
||||
\commentary{
|
||||
A 64 bit double precision floating point number
|
||||
is usually taken to represent a range of real numbers
|
||||
@@ -7212,23 +7219,27 @@ Evaluation of an expression of the form \code{-{}-$e$} is equivalent to \code{$e
|
||||
\LMHash{}
|
||||
If $e$ is an expression of the form \code{-$l$}
|
||||
where $l$ is an integer literal (\ref{numbers}) with numeric integer value $i$,
|
||||
then the static type of $e$ is the same as the static type of an integer literal
|
||||
with the same context type,
|
||||
and evaluation of $e$ first proceeds as for an integer literal
|
||||
with numeric value $-i$, evaluating to a value $v$.
|
||||
Then, if the static type of the $e$ is \code{double} and $v$ is the \code{double} value 0.0, then $e$ evaluates to the \code{double} value -0.0,
|
||||
otherwise $e$ evaluates to $v$.
|
||||
and with static contex type $T$.
|
||||
If \code{double} is assignable to $T$ and \code{int} is not assignable to $T$,
|
||||
then the static type of $e$ is \code{double};
|
||||
otherwise the static type of $e$ is \code{int}.
|
||||
|
||||
\LMHash{}
|
||||
If the static type of $e$ is \code{int} then $e$ evaluates to
|
||||
to an instance of the \code{int} class representing the numeric value $-i$.
|
||||
It is a compile-time error if the integer $-i$ cannot be represented
|
||||
exactly by an instance of \code{int}.
|
||||
|
||||
\LMHash{}
|
||||
If the static type of $e$ is \code{double} then $e$ evaluates to
|
||||
to an instance of the \code{double} class representing the numeric value $-i$.
|
||||
It is a compile-time error if the integer $-i$ cannot be represented
|
||||
exactly by an instance of \code{double}.
|
||||
\commentary{
|
||||
We treat \code{-$l$} \emph{as if} it is a single integer literal with a negative
|
||||
numeric value. The specified semantics of integer literals (\ref{numbers})
|
||||
allows negative numeric values, so they can be applied as-is to the value $-i$,
|
||||
except that we want \code{-0} in a \code{double} context
|
||||
to evaluate to \code{-0.0}.
|
||||
The expression \code{-$l$} is not \emph{itself} an integer literal,
|
||||
it's merely treated as one,
|
||||
so this rule does not apply twice to \code{- -$l$}.
|
||||
It also does not apply to \code{-($l$)}
|
||||
since a parenthesized expression is not an integer literal expression.
|
||||
We treat \code{-$l$} \emph{as if} it is a single integer literal
|
||||
with a negative numeric value.
|
||||
We do not evaluate $l$ individually as an expression,
|
||||
or concern ourselves with its static type.
|
||||
}
|
||||
|
||||
\LMHash{}
|
||||
|
||||
@@ -79,217 +79,221 @@ main() {
|
||||
18446744073709553664, // 2^64+2^11 //# 067: compile-time error
|
||||
179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858367, // maxValue - 1 //# 068 : compile-time error
|
||||
179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858369, // maxValue + 1 //# 069 : compile-time error
|
||||
359538626972463141629054847463408713596141135051689993197834953606314521560057077521179117265533756343080917907028764928468642653778928365536935093407075033972099821153102564152490980180778657888151737016910267884609166473806445896331617118664246696549595652408289446337476354361838599762500808052368249716734, // maxValue * 2 //# 070P : compile-time error
|
||||
|
||||
// Negative numbers too.
|
||||
-9007199254740993, // -(2^53+2^0) //# 070: compile-time error
|
||||
-18014398509481983, // -(2^54-2^0) //# 071: compile-time error
|
||||
-18014398509481985, // -(2^54+2^0) //# 072: compile-time error
|
||||
-18014398509481986, // -(2^54+2^1) //# 073: compile-time error
|
||||
-4611686018427387903, // -(2^62-2^0) //# 074: compile-time error
|
||||
-4611686018427387902, // -(2^62-2^1) //# 075: compile-time error
|
||||
-4611686018427387900, // -(2^62-2^2) //# 076: compile-time error
|
||||
-4611686018427387896, // -(2^62-2^3) //# 077: compile-time error
|
||||
-4611686018427387888, // -(2^62-2^4) //# 078: compile-time error
|
||||
-4611686018427387872, // -(2^62-2^5) //# 079: compile-time error
|
||||
-4611686018427387840, // -(2^62-2^6) //# 080: compile-time error
|
||||
-4611686018427387776, // -(2^62-2^7) //# 081: compile-time error
|
||||
-4611686018427387648, // -(2^62-2^8) //# 082: compile-time error
|
||||
-4611686018427387905, // -(2^62+2^0) //# 083: compile-time error
|
||||
-4611686018427387906, // -(2^62+2^1) //# 084: compile-time error
|
||||
-4611686018427387908, // -(2^62+2^2) //# 085: compile-time error
|
||||
-4611686018427387912, // -(2^62+2^3) //# 086: compile-time error
|
||||
-4611686018427387920, // -(2^62+2^4) //# 087: compile-time error
|
||||
-4611686018427387936, // -(2^62+2^5) //# 088: compile-time error
|
||||
-4611686018427387968, // -(2^62+2^6) //# 089: compile-time error
|
||||
-4611686018427388032, // -(2^62+2^7) //# 090: compile-time error
|
||||
-4611686018427388160, // -(2^62+2^8) //# 091: compile-time error
|
||||
-4611686018427388416, // -(2^62+2^9) //# 092: compile-time error
|
||||
-9223372036854775807, // -(2^63-2^0) //# 093: compile-time error
|
||||
-9223372036854775806, // -(2^63-2^1) //# 094: compile-time error
|
||||
-9223372036854775804, // -(2^63-2^2) //# 095: compile-time error
|
||||
-9223372036854775800, // -(2^63-2^3) //# 096: compile-time error
|
||||
-9223372036854775792, // -(2^63-2^4) //# 097: compile-time error
|
||||
-9223372036854775776, // -(2^63-2^5) //# 098: compile-time error
|
||||
-9223372036854775744, // -(2^63-2^6) //# 099: compile-time error
|
||||
-9223372036854775680, // -(2^63-2^7) //# 100: compile-time error
|
||||
-9223372036854775552, // -(2^63-2^8) //# 101: compile-time error
|
||||
-9223372036854775296, // -(2^63-2^9) //# 102: compile-time error
|
||||
-9223372036854775809, // -(2^63+2^0) //# 103: compile-time error
|
||||
-9223372036854775810, // -(2^63+2^1) //# 104: compile-time error
|
||||
-9223372036854775812, // -(2^63+2^2) //# 105: compile-time error
|
||||
-9223372036854775816, // -(2^63+2^3) //# 106: compile-time error
|
||||
-9223372036854775824, // -(2^63+2^4) //# 107: compile-time error
|
||||
-9223372036854775840, // -(2^63+2^5) //# 108: compile-time error
|
||||
-9223372036854775872, // -(2^63+2^6) //# 109: compile-time error
|
||||
-9223372036854775936, // -(2^63+2^7) //# 110: compile-time error
|
||||
-9223372036854776064, // -(2^63+2^8) //# 111: compile-time error
|
||||
-9223372036854776320, // -(2^63+2^9) //# 112: compile-time error
|
||||
-9223372036854776832, // -(2^63+2^10) //# 113: compile-time error
|
||||
-18446744073709551615, // -(2^64-2^0) //# 114: compile-time error
|
||||
-18446744073709551614, // -(2^64-2^1) //# 115: compile-time error
|
||||
-18446744073709551612, // -(2^64-2^2) //# 116: compile-time error
|
||||
-18446744073709551608, // -(2^64-2^3) //# 117: compile-time error
|
||||
-18446744073709551600, // -(2^64-2^4) //# 118: compile-time error
|
||||
-18446744073709551584, // -(2^64-2^5) //# 119: compile-time error
|
||||
-18446744073709551552, // -(2^64-2^6) //# 120: compile-time error
|
||||
-18446744073709551488, // -(2^64-2^7) //# 121: compile-time error
|
||||
-18446744073709551360, // -(2^64-2^8) //# 122: compile-time error
|
||||
-18446744073709551104, // -(2^64-2^9) //# 123: compile-time error
|
||||
-18446744073709550592, // -(2^64-2^10) //# 124: compile-time error
|
||||
-18446744073709551617, // -(2^64+2^0) //# 125: compile-time error
|
||||
-18446744073709551618, // -(2^64+2^1) //# 126: compile-time error
|
||||
-18446744073709551620, // -(2^64+2^2) //# 127: compile-time error
|
||||
-18446744073709551624, // -(2^64+2^3) //# 128: compile-time error
|
||||
-18446744073709551632, // -(2^64+2^4) //# 129: compile-time error
|
||||
-18446744073709551648, // -(2^64+2^5) //# 130: compile-time error
|
||||
-18446744073709551680, // -(2^64+2^6) //# 131: compile-time error
|
||||
-18446744073709551744, // -(2^64+2^7) //# 132: compile-time error
|
||||
-18446744073709551872, // -(2^64+2^8) //# 133: compile-time error
|
||||
-18446744073709552128, // -(2^64+2^9) //# 134: compile-time error
|
||||
-18446744073709552640, // -(2^64+2^10) //# 135: compile-time error
|
||||
-18446744073709553664, // -(2^64+2^11) //# 136: compile-time error
|
||||
-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858367, // -(maxValue - 1) //# 137 : compile-time error
|
||||
-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858369, // -(maxValue + 1) //# 138 : compile-time error
|
||||
-9007199254740993, // -(2^53+2^0) //# 071: compile-time error
|
||||
-18014398509481983, // -(2^54-2^0) //# 072: compile-time error
|
||||
-18014398509481985, // -(2^54+2^0) //# 073: compile-time error
|
||||
-18014398509481986, // -(2^54+2^1) //# 074: compile-time error
|
||||
-4611686018427387903, // -(2^62-2^0) //# 075: compile-time error
|
||||
-4611686018427387902, // -(2^62-2^1) //# 076: compile-time error
|
||||
-4611686018427387900, // -(2^62-2^2) //# 077: compile-time error
|
||||
-4611686018427387896, // -(2^62-2^3) //# 078: compile-time error
|
||||
-4611686018427387888, // -(2^62-2^4) //# 079: compile-time error
|
||||
-4611686018427387872, // -(2^62-2^5) //# 080: compile-time error
|
||||
-4611686018427387840, // -(2^62-2^6) //# 081: compile-time error
|
||||
-4611686018427387776, // -(2^62-2^7) //# 082: compile-time error
|
||||
-4611686018427387648, // -(2^62-2^8) //# 083: compile-time error
|
||||
-4611686018427387905, // -(2^62+2^0) //# 084: compile-time error
|
||||
-4611686018427387906, // -(2^62+2^1) //# 085: compile-time error
|
||||
-4611686018427387908, // -(2^62+2^2) //# 086: compile-time error
|
||||
-4611686018427387912, // -(2^62+2^3) //# 087: compile-time error
|
||||
-4611686018427387920, // -(2^62+2^4) //# 088: compile-time error
|
||||
-4611686018427387936, // -(2^62+2^5) //# 089: compile-time error
|
||||
-4611686018427387968, // -(2^62+2^6) //# 090: compile-time error
|
||||
-4611686018427388032, // -(2^62+2^7) //# 091: compile-time error
|
||||
-4611686018427388160, // -(2^62+2^8) //# 092: compile-time error
|
||||
-4611686018427388416, // -(2^62+2^9) //# 093: compile-time error
|
||||
-9223372036854775807, // -(2^63-2^0) //# 094: compile-time error
|
||||
-9223372036854775806, // -(2^63-2^1) //# 095: compile-time error
|
||||
-9223372036854775804, // -(2^63-2^2) //# 096: compile-time error
|
||||
-9223372036854775800, // -(2^63-2^3) //# 097: compile-time error
|
||||
-9223372036854775792, // -(2^63-2^4) //# 098: compile-time error
|
||||
-9223372036854775776, // -(2^63-2^5) //# 099: compile-time error
|
||||
-9223372036854775744, // -(2^63-2^6) //# 100: compile-time error
|
||||
-9223372036854775680, // -(2^63-2^7) //# 101: compile-time error
|
||||
-9223372036854775552, // -(2^63-2^8) //# 102: compile-time error
|
||||
-9223372036854775296, // -(2^63-2^9) //# 103: compile-time error
|
||||
-9223372036854775809, // -(2^63+2^0) //# 104: compile-time error
|
||||
-9223372036854775810, // -(2^63+2^1) //# 105: compile-time error
|
||||
-9223372036854775812, // -(2^63+2^2) //# 106: compile-time error
|
||||
-9223372036854775816, // -(2^63+2^3) //# 107: compile-time error
|
||||
-9223372036854775824, // -(2^63+2^4) //# 108: compile-time error
|
||||
-9223372036854775840, // -(2^63+2^5) //# 109: compile-time error
|
||||
-9223372036854775872, // -(2^63+2^6) //# 110: compile-time error
|
||||
-9223372036854775936, // -(2^63+2^7) //# 111: compile-time error
|
||||
-9223372036854776064, // -(2^63+2^8) //# 112: compile-time error
|
||||
-9223372036854776320, // -(2^63+2^9) //# 113: compile-time error
|
||||
-9223372036854776832, // -(2^63+2^10) //# 114: compile-time error
|
||||
-18446744073709551615, // -(2^64-2^0) //# 115: compile-time error
|
||||
-18446744073709551614, // -(2^64-2^1) //# 116: compile-time error
|
||||
-18446744073709551612, // -(2^64-2^2) //# 117: compile-time error
|
||||
-18446744073709551608, // -(2^64-2^3) //# 118: compile-time error
|
||||
-18446744073709551600, // -(2^64-2^4) //# 119: compile-time error
|
||||
-18446744073709551584, // -(2^64-2^5) //# 120: compile-time error
|
||||
-18446744073709551552, // -(2^64-2^6) //# 121: compile-time error
|
||||
-18446744073709551488, // -(2^64-2^7) //# 122: compile-time error
|
||||
-18446744073709551360, // -(2^64-2^8) //# 123: compile-time error
|
||||
-18446744073709551104, // -(2^64-2^9) //# 124: compile-time error
|
||||
-18446744073709550592, // -(2^64-2^10) //# 125: compile-time error
|
||||
-18446744073709551617, // -(2^64+2^0) //# 126: compile-time error
|
||||
-18446744073709551618, // -(2^64+2^1) //# 127: compile-time error
|
||||
-18446744073709551620, // -(2^64+2^2) //# 128: compile-time error
|
||||
-18446744073709551624, // -(2^64+2^3) //# 129: compile-time error
|
||||
-18446744073709551632, // -(2^64+2^4) //# 130: compile-time error
|
||||
-18446744073709551648, // -(2^64+2^5) //# 131: compile-time error
|
||||
-18446744073709551680, // -(2^64+2^6) //# 132: compile-time error
|
||||
-18446744073709551744, // -(2^64+2^7) //# 133: compile-time error
|
||||
-18446744073709551872, // -(2^64+2^8) //# 134: compile-time error
|
||||
-18446744073709552128, // -(2^64+2^9) //# 135: compile-time error
|
||||
-18446744073709552640, // -(2^64+2^10) //# 136: compile-time error
|
||||
-18446744073709553664, // -(2^64+2^11) //# 137: compile-time error
|
||||
-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858367, // -(maxValue - 1) //# 138 : compile-time error
|
||||
-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858369, // -(maxValue + 1) //# 139 : compile-time error
|
||||
-359538626972463141629054847463408713596141135051689993197834953606314521560057077521179117265533756343080917907028764928468642653778928365536935093407075033972099821153102564152490980180778657888151737016910267884609166473806445896331617118664246696549595652408289446337476354361838599762500808052368249716734, // -(maxValue * 2) //# 140B : compile-time error
|
||||
|
||||
// Same numbers as hexadecimal literals.
|
||||
0x20000000000001, // 2^53+2^0 //# 139: compile-time error
|
||||
0x3fffffffffffff, // 2^54-2^0 //# 140: compile-time error
|
||||
0x40000000000001, // 2^54+2^0 //# 141: compile-time error
|
||||
0x40000000000002, // 2^54+2^1 //# 142: compile-time error
|
||||
0x3fffffffffffffff, // 2^62-2^0 //# 143: compile-time error
|
||||
0x3ffffffffffffffe, // 2^62-2^1 //# 144: compile-time error
|
||||
0x3ffffffffffffffc, // 2^62-2^2 //# 145: compile-time error
|
||||
0x3ffffffffffffff8, // 2^62-2^3 //# 146: compile-time error
|
||||
0x3ffffffffffffff0, // 2^62-2^4 //# 147: compile-time error
|
||||
0x3fffffffffffffe0, // 2^62-2^5 //# 148: compile-time error
|
||||
0x3fffffffffffffc0, // 2^62-2^6 //# 149: compile-time error
|
||||
0x3fffffffffffff80, // 2^62-2^7 //# 150: compile-time error
|
||||
0x3fffffffffffff00, // 2^62-2^8 //# 151: compile-time error
|
||||
0x4000000000000001, // 2^62+2^0 //# 152: compile-time error
|
||||
0x4000000000000002, // 2^62+2^1 //# 153: compile-time error
|
||||
0x4000000000000004, // 2^62+2^2 //# 154: compile-time error
|
||||
0x4000000000000008, // 2^62+2^3 //# 155: compile-time error
|
||||
0x4000000000000010, // 2^62+2^4 //# 156: compile-time error
|
||||
0x4000000000000020, // 2^62+2^5 //# 157: compile-time error
|
||||
0x4000000000000040, // 2^62+2^6 //# 158: compile-time error
|
||||
0x4000000000000080, // 2^62+2^7 //# 159: compile-time error
|
||||
0x4000000000000100, // 2^62+2^8 //# 160: compile-time error
|
||||
0x4000000000000200, // 2^62+2^9 //# 161: compile-time error
|
||||
0x7fffffffffffffff, // 2^63-2^0 //# 162: compile-time error
|
||||
0x7ffffffffffffffe, // 2^63-2^1 //# 163: compile-time error
|
||||
0x7ffffffffffffffc, // 2^63-2^2 //# 164: compile-time error
|
||||
0x7ffffffffffffff8, // 2^63-2^3 //# 165: compile-time error
|
||||
0x7ffffffffffffff0, // 2^63-2^4 //# 166: compile-time error
|
||||
0x7fffffffffffffe0, // 2^63-2^5 //# 167: compile-time error
|
||||
0x7fffffffffffffc0, // 2^63-2^6 //# 168: compile-time error
|
||||
0x7fffffffffffff80, // 2^63-2^7 //# 169: compile-time error
|
||||
0x7fffffffffffff00, // 2^63-2^8 //# 170: compile-time error
|
||||
0x7ffffffffffffe00, // 2^63-2^9 //# 171: compile-time error
|
||||
0x8000000000000001, // 2^63+2^0 //# 172: compile-time error
|
||||
0x8000000000000002, // 2^63+2^1 //# 173: compile-time error
|
||||
0x8000000000000004, // 2^63+2^2 //# 174: compile-time error
|
||||
0x8000000000000008, // 2^63+2^3 //# 175: compile-time error
|
||||
0x8000000000000010, // 2^63+2^4 //# 176: compile-time error
|
||||
0x8000000000000020, // 2^63+2^5 //# 177: compile-time error
|
||||
0x8000000000000040, // 2^63+2^6 //# 178: compile-time error
|
||||
0x8000000000000080, // 2^63+2^7 //# 179: compile-time error
|
||||
0x8000000000000100, // 2^63+2^8 //# 180: compile-time error
|
||||
0x8000000000000200, // 2^63+2^9 //# 181: compile-time error
|
||||
0x8000000000000400, // 2^63+2^10 //# 182: compile-time error
|
||||
0xffffffffffffffff, // 2^64-2^0 //# 183: compile-time error
|
||||
0xfffffffffffffffe, // 2^64-2^1 //# 184: compile-time error
|
||||
0xfffffffffffffffc, // 2^64-2^2 //# 185: compile-time error
|
||||
0xfffffffffffffff8, // 2^64-2^3 //# 186: compile-time error
|
||||
0xfffffffffffffff0, // 2^64-2^4 //# 187: compile-time error
|
||||
0xffffffffffffffe0, // 2^64-2^5 //# 188: compile-time error
|
||||
0xffffffffffffffc0, // 2^64-2^6 //# 189: compile-time error
|
||||
0xffffffffffffff80, // 2^64-2^7 //# 190: compile-time error
|
||||
0xffffffffffffff00, // 2^64-2^8 //# 191: compile-time error
|
||||
0xfffffffffffffe00, // 2^64-2^9 //# 192: compile-time error
|
||||
0xfffffffffffffc00, // 2^64-2^10 //# 193: compile-time error
|
||||
0x10000000000000001, // 2^64+2^0 //# 194: compile-time error
|
||||
0x10000000000000002, // 2^64+2^1 //# 195: compile-time error
|
||||
0x10000000000000004, // 2^64+2^2 //# 196: compile-time error
|
||||
0x10000000000000008, // 2^64+2^3 //# 197: compile-time error
|
||||
0x10000000000000010, // 2^64+2^4 //# 198: compile-time error
|
||||
0x10000000000000020, // 2^64+2^5 //# 199: compile-time error
|
||||
0x10000000000000040, // 2^64+2^6 //# 200: compile-time error
|
||||
0x10000000000000080, // 2^64+2^7 //# 201: compile-time error
|
||||
0x10000000000000100, // 2^64+2^8 //# 202: compile-time error
|
||||
0x10000000000000200, // 2^64+2^9 //# 203: compile-time error
|
||||
0x10000000000000400, // 2^64+2^10 //# 204: compile-time error
|
||||
0x10000000000000800, // 2^64+2^11 //# 205: compile-time error
|
||||
0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, // maxValue - 1 //# 206 : compile-time error
|
||||
0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001, // maxValue + 1 //# 207 : compile-time error
|
||||
0x20000000000001, // 2^53+2^0 //# 141: compile-time error
|
||||
0x3fffffffffffff, // 2^54-2^0 //# 142: compile-time error
|
||||
0x40000000000001, // 2^54+2^0 //# 143: compile-time error
|
||||
0x40000000000002, // 2^54+2^1 //# 144: compile-time error
|
||||
0x3fffffffffffffff, // 2^62-2^0 //# 145: compile-time error
|
||||
0x3ffffffffffffffe, // 2^62-2^1 //# 146: compile-time error
|
||||
0x3ffffffffffffffc, // 2^62-2^2 //# 147: compile-time error
|
||||
0x3ffffffffffffff8, // 2^62-2^3 //# 148: compile-time error
|
||||
0x3ffffffffffffff0, // 2^62-2^4 //# 149: compile-time error
|
||||
0x3fffffffffffffe0, // 2^62-2^5 //# 150: compile-time error
|
||||
0x3fffffffffffffc0, // 2^62-2^6 //# 151: compile-time error
|
||||
0x3fffffffffffff80, // 2^62-2^7 //# 152: compile-time error
|
||||
0x3fffffffffffff00, // 2^62-2^8 //# 153: compile-time error
|
||||
0x4000000000000001, // 2^62+2^0 //# 154: compile-time error
|
||||
0x4000000000000002, // 2^62+2^1 //# 155: compile-time error
|
||||
0x4000000000000004, // 2^62+2^2 //# 156: compile-time error
|
||||
0x4000000000000008, // 2^62+2^3 //# 157: compile-time error
|
||||
0x4000000000000010, // 2^62+2^4 //# 158: compile-time error
|
||||
0x4000000000000020, // 2^62+2^5 //# 159: compile-time error
|
||||
0x4000000000000040, // 2^62+2^6 //# 160: compile-time error
|
||||
0x4000000000000080, // 2^62+2^7 //# 161: compile-time error
|
||||
0x4000000000000100, // 2^62+2^8 //# 162: compile-time error
|
||||
0x4000000000000200, // 2^62+2^9 //# 163: compile-time error
|
||||
0x7fffffffffffffff, // 2^63-2^0 //# 164: compile-time error
|
||||
0x7ffffffffffffffe, // 2^63-2^1 //# 165: compile-time error
|
||||
0x7ffffffffffffffc, // 2^63-2^2 //# 166: compile-time error
|
||||
0x7ffffffffffffff8, // 2^63-2^3 //# 167: compile-time error
|
||||
0x7ffffffffffffff0, // 2^63-2^4 //# 168: compile-time error
|
||||
0x7fffffffffffffe0, // 2^63-2^5 //# 169: compile-time error
|
||||
0x7fffffffffffffc0, // 2^63-2^6 //# 170: compile-time error
|
||||
0x7fffffffffffff80, // 2^63-2^7 //# 171: compile-time error
|
||||
0x7fffffffffffff00, // 2^63-2^8 //# 172: compile-time error
|
||||
0x7ffffffffffffe00, // 2^63-2^9 //# 173: compile-time error
|
||||
0x8000000000000001, // 2^63+2^0 //# 174: compile-time error
|
||||
0x8000000000000002, // 2^63+2^1 //# 175: compile-time error
|
||||
0x8000000000000004, // 2^63+2^2 //# 176: compile-time error
|
||||
0x8000000000000008, // 2^63+2^3 //# 177: compile-time error
|
||||
0x8000000000000010, // 2^63+2^4 //# 178: compile-time error
|
||||
0x8000000000000020, // 2^63+2^5 //# 179: compile-time error
|
||||
0x8000000000000040, // 2^63+2^6 //# 180: compile-time error
|
||||
0x8000000000000080, // 2^63+2^7 //# 181: compile-time error
|
||||
0x8000000000000100, // 2^63+2^8 //# 182: compile-time error
|
||||
0x8000000000000200, // 2^63+2^9 //# 183: compile-time error
|
||||
0x8000000000000400, // 2^63+2^10 //# 184: compile-time error
|
||||
0xffffffffffffffff, // 2^64-2^0 //# 185: compile-time error
|
||||
0xfffffffffffffffe, // 2^64-2^1 //# 186: compile-time error
|
||||
0xfffffffffffffffc, // 2^64-2^2 //# 187: compile-time error
|
||||
0xfffffffffffffff8, // 2^64-2^3 //# 188: compile-time error
|
||||
0xfffffffffffffff0, // 2^64-2^4 //# 189: compile-time error
|
||||
0xffffffffffffffe0, // 2^64-2^5 //# 190: compile-time error
|
||||
0xffffffffffffffc0, // 2^64-2^6 //# 191: compile-time error
|
||||
0xffffffffffffff80, // 2^64-2^7 //# 192: compile-time error
|
||||
0xffffffffffffff00, // 2^64-2^8 //# 193: compile-time error
|
||||
0xfffffffffffffe00, // 2^64-2^9 //# 194: compile-time error
|
||||
0xfffffffffffffc00, // 2^64-2^10 //# 195: compile-time error
|
||||
0x10000000000000001, // 2^64+2^0 //# 196: compile-time error
|
||||
0x10000000000000002, // 2^64+2^1 //# 197: compile-time error
|
||||
0x10000000000000004, // 2^64+2^2 //# 198: compile-time error
|
||||
0x10000000000000008, // 2^64+2^3 //# 199: compile-time error
|
||||
0x10000000000000010, // 2^64+2^4 //# 200: compile-time error
|
||||
0x10000000000000020, // 2^64+2^5 //# 201: compile-time error
|
||||
0x10000000000000040, // 2^64+2^6 //# 202: compile-time error
|
||||
0x10000000000000080, // 2^64+2^7 //# 203: compile-time error
|
||||
0x10000000000000100, // 2^64+2^8 //# 204: compile-time error
|
||||
0x10000000000000200, // 2^64+2^9 //# 205: compile-time error
|
||||
0x10000000000000400, // 2^64+2^10 //# 206: compile-time error
|
||||
0x10000000000000800, // 2^64+2^11 //# 207: compile-time error
|
||||
0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, // maxValue - 1 //# 208 : compile-time error
|
||||
0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001, // maxValue + 1 //# 209 : compile-time error
|
||||
0x1fffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001, // maxValue * 2 //# 210V : compile-time error
|
||||
|
||||
-0x20000000000001, // -(2^53+2^0) //# 208: compile-time error
|
||||
-0x3fffffffffffff, // -(2^54-2^0) //# 209: compile-time error
|
||||
-0x40000000000001, // -(2^54+2^0) //# 210: compile-time error
|
||||
-0x40000000000002, // -(2^54+2^1) //# 211: compile-time error
|
||||
-0x3fffffffffffffff, // -(2^62-2^0) //# 212: compile-time error
|
||||
-0x3ffffffffffffffe, // -(2^62-2^1) //# 213: compile-time error
|
||||
-0x3ffffffffffffffc, // -(2^62-2^2) //# 214: compile-time error
|
||||
-0x3ffffffffffffff8, // -(2^62-2^3) //# 215: compile-time error
|
||||
-0x3ffffffffffffff0, // -(2^62-2^4) //# 216: compile-time error
|
||||
-0x3fffffffffffffe0, // -(2^62-2^5) //# 217: compile-time error
|
||||
-0x3fffffffffffffc0, // -(2^62-2^6) //# 218: compile-time error
|
||||
-0x3fffffffffffff80, // -(2^62-2^7) //# 219: compile-time error
|
||||
-0x3fffffffffffff00, // -(2^62-2^8) //# 220: compile-time error
|
||||
-0x4000000000000001, // -(2^62+2^0) //# 221: compile-time error
|
||||
-0x4000000000000002, // -(2^62+2^1) //# 222: compile-time error
|
||||
-0x4000000000000004, // -(2^62+2^2) //# 223: compile-time error
|
||||
-0x4000000000000008, // -(2^62+2^3) //# 224: compile-time error
|
||||
-0x4000000000000010, // -(2^62+2^4) //# 225: compile-time error
|
||||
-0x4000000000000020, // -(2^62+2^5) //# 226: compile-time error
|
||||
-0x4000000000000040, // -(2^62+2^6) //# 227: compile-time error
|
||||
-0x4000000000000080, // -(2^62+2^7) //# 228: compile-time error
|
||||
-0x4000000000000100, // -(2^62+2^8) //# 229: compile-time error
|
||||
-0x4000000000000200, // -(2^62+2^9) //# 230: compile-time error
|
||||
-0x7fffffffffffffff, // -(2^63-2^0) //# 231: compile-time error
|
||||
-0x7ffffffffffffffe, // -(2^63-2^1) //# 232: compile-time error
|
||||
-0x7ffffffffffffffc, // -(2^63-2^2) //# 233: compile-time error
|
||||
-0x7ffffffffffffff8, // -(2^63-2^3) //# 234: compile-time error
|
||||
-0x7ffffffffffffff0, // -(2^63-2^4) //# 235: compile-time error
|
||||
-0x7fffffffffffffe0, // -(2^63-2^5) //# 236: compile-time error
|
||||
-0x7fffffffffffffc0, // -(2^63-2^6) //# 237: compile-time error
|
||||
-0x7fffffffffffff80, // -(2^63-2^7) //# 238: compile-time error
|
||||
-0x7fffffffffffff00, // -(2^63-2^8) //# 239: compile-time error
|
||||
-0x7ffffffffffffe00, // -(2^63-2^9) //# 240: compile-time error
|
||||
-0x8000000000000001, // -(2^63+2^0) //# 241: compile-time error
|
||||
-0x8000000000000002, // -(2^63+2^1) //# 242: compile-time error
|
||||
-0x8000000000000004, // -(2^63+2^2) //# 243: compile-time error
|
||||
-0x8000000000000008, // -(2^63+2^3) //# 244: compile-time error
|
||||
-0x8000000000000010, // -(2^63+2^4) //# 245: compile-time error
|
||||
-0x8000000000000020, // -(2^63+2^5) //# 246: compile-time error
|
||||
-0x8000000000000040, // -(2^63+2^6) //# 247: compile-time error
|
||||
-0x8000000000000080, // -(2^63+2^7) //# 248: compile-time error
|
||||
-0x8000000000000100, // -(2^63+2^8) //# 249: compile-time error
|
||||
-0x8000000000000200, // -(2^63+2^9) //# 250: compile-time error
|
||||
-0x8000000000000400, // -(2^63+2^10) //# 251: compile-time error
|
||||
-0xffffffffffffffff, // -(2^64-2^0) //# 252: compile-time error
|
||||
-0xfffffffffffffffe, // -(2^64-2^1) //# 253: compile-time error
|
||||
-0xfffffffffffffffc, // -(2^64-2^2) //# 254: compile-time error
|
||||
-0xfffffffffffffff8, // -(2^64-2^3) //# 255: compile-time error
|
||||
-0xfffffffffffffff0, // -(2^64-2^4) //# 256: compile-time error
|
||||
-0xffffffffffffffe0, // -(2^64-2^5) //# 257: compile-time error
|
||||
-0xffffffffffffffc0, // -(2^64-2^6) //# 258: compile-time error
|
||||
-0xffffffffffffff80, // -(2^64-2^7) //# 259: compile-time error
|
||||
-0xffffffffffffff00, // -(2^64-2^8) //# 260: compile-time error
|
||||
-0xfffffffffffffe00, // -(2^64-2^9) //# 261: compile-time error
|
||||
-0xfffffffffffffc00, // -(2^64-2^10) //# 262: compile-time error
|
||||
-0x10000000000000001, // -(2^64+2^0) //# 263: compile-time error
|
||||
-0x10000000000000002, // -(2^64+2^1) //# 264: compile-time error
|
||||
-0x10000000000000004, // -(2^64+2^2) //# 265: compile-time error
|
||||
-0x10000000000000008, // -(2^64+2^3) //# 266: compile-time error
|
||||
-0x10000000000000010, // -(2^64+2^4) //# 267: compile-time error
|
||||
-0x10000000000000020, // -(2^64+2^5) //# 268: compile-time error
|
||||
-0x10000000000000040, // -(2^64+2^6) //# 269: compile-time error
|
||||
-0x10000000000000080, // -(2^64+2^7) //# 270: compile-time error
|
||||
-0x10000000000000100, // -(2^64+2^8) //# 271: compile-time error
|
||||
-0x10000000000000200, // -(2^64+2^9) //# 272: compile-time error
|
||||
-0x10000000000000400, // -(2^64+2^10) //# 273: compile-time error
|
||||
-0x10000000000000800, // -(2^64+2^11) //# 274: compile-time error
|
||||
-0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, // -(maxValue - 1) //# 275 : compile-time error
|
||||
-0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001, // -(maxValue + 1) //# 276 : compile-time error
|
||||
-0x20000000000001, // -(2^53+2^0) //# 211: compile-time error
|
||||
-0x3fffffffffffff, // -(2^54-2^0) //# 212: compile-time error
|
||||
-0x40000000000001, // -(2^54+2^0) //# 213: compile-time error
|
||||
-0x40000000000002, // -(2^54+2^1) //# 214: compile-time error
|
||||
-0x3fffffffffffffff, // -(2^62-2^0) //# 215: compile-time error
|
||||
-0x3ffffffffffffffe, // -(2^62-2^1) //# 216: compile-time error
|
||||
-0x3ffffffffffffffc, // -(2^62-2^2) //# 217: compile-time error
|
||||
-0x3ffffffffffffff8, // -(2^62-2^3) //# 218: compile-time error
|
||||
-0x3ffffffffffffff0, // -(2^62-2^4) //# 219: compile-time error
|
||||
-0x3fffffffffffffe0, // -(2^62-2^5) //# 220: compile-time error
|
||||
-0x3fffffffffffffc0, // -(2^62-2^6) //# 221: compile-time error
|
||||
-0x3fffffffffffff80, // -(2^62-2^7) //# 222: compile-time error
|
||||
-0x3fffffffffffff00, // -(2^62-2^8) //# 223: compile-time error
|
||||
-0x4000000000000001, // -(2^62+2^0) //# 224: compile-time error
|
||||
-0x4000000000000002, // -(2^62+2^1) //# 225: compile-time error
|
||||
-0x4000000000000004, // -(2^62+2^2) //# 226: compile-time error
|
||||
-0x4000000000000008, // -(2^62+2^3) //# 227: compile-time error
|
||||
-0x4000000000000010, // -(2^62+2^4) //# 228: compile-time error
|
||||
-0x4000000000000020, // -(2^62+2^5) //# 229: compile-time error
|
||||
-0x4000000000000040, // -(2^62+2^6) //# 230: compile-time error
|
||||
-0x4000000000000080, // -(2^62+2^7) //# 231: compile-time error
|
||||
-0x4000000000000100, // -(2^62+2^8) //# 232: compile-time error
|
||||
-0x4000000000000200, // -(2^62+2^9) //# 233: compile-time error
|
||||
-0x7fffffffffffffff, // -(2^63-2^0) //# 234: compile-time error
|
||||
-0x7ffffffffffffffe, // -(2^63-2^1) //# 235: compile-time error
|
||||
-0x7ffffffffffffffc, // -(2^63-2^2) //# 236: compile-time error
|
||||
-0x7ffffffffffffff8, // -(2^63-2^3) //# 237: compile-time error
|
||||
-0x7ffffffffffffff0, // -(2^63-2^4) //# 238: compile-time error
|
||||
-0x7fffffffffffffe0, // -(2^63-2^5) //# 239: compile-time error
|
||||
-0x7fffffffffffffc0, // -(2^63-2^6) //# 240: compile-time error
|
||||
-0x7fffffffffffff80, // -(2^63-2^7) //# 241: compile-time error
|
||||
-0x7fffffffffffff00, // -(2^63-2^8) //# 242: compile-time error
|
||||
-0x7ffffffffffffe00, // -(2^63-2^9) //# 243: compile-time error
|
||||
-0x8000000000000001, // -(2^63+2^0) //# 244: compile-time error
|
||||
-0x8000000000000002, // -(2^63+2^1) //# 245: compile-time error
|
||||
-0x8000000000000004, // -(2^63+2^2) //# 246: compile-time error
|
||||
-0x8000000000000008, // -(2^63+2^3) //# 247: compile-time error
|
||||
-0x8000000000000010, // -(2^63+2^4) //# 248: compile-time error
|
||||
-0x8000000000000020, // -(2^63+2^5) //# 249: compile-time error
|
||||
-0x8000000000000040, // -(2^63+2^6) //# 250: compile-time error
|
||||
-0x8000000000000080, // -(2^63+2^7) //# 251: compile-time error
|
||||
-0x8000000000000100, // -(2^63+2^8) //# 252: compile-time error
|
||||
-0x8000000000000200, // -(2^63+2^9) //# 253: compile-time error
|
||||
-0x8000000000000400, // -(2^63+2^10) //# 254: compile-time error
|
||||
-0xffffffffffffffff, // -(2^64-2^0) //# 255: compile-time error
|
||||
-0xfffffffffffffffe, // -(2^64-2^1) //# 256: compile-time error
|
||||
-0xfffffffffffffffc, // -(2^64-2^2) //# 257: compile-time error
|
||||
-0xfffffffffffffff8, // -(2^64-2^3) //# 258: compile-time error
|
||||
-0xfffffffffffffff0, // -(2^64-2^4) //# 259: compile-time error
|
||||
-0xffffffffffffffe0, // -(2^64-2^5) //# 260: compile-time error
|
||||
-0xffffffffffffffc0, // -(2^64-2^6) //# 261: compile-time error
|
||||
-0xffffffffffffff80, // -(2^64-2^7) //# 262: compile-time error
|
||||
-0xffffffffffffff00, // -(2^64-2^8) //# 263: compile-time error
|
||||
-0xfffffffffffffe00, // -(2^64-2^9) //# 264: compile-time error
|
||||
-0xfffffffffffffc00, // -(2^64-2^10) //# 265: compile-time error
|
||||
-0x10000000000000001, // -(2^64+2^0) //# 266: compile-time error
|
||||
-0x10000000000000002, // -(2^64+2^1) //# 267: compile-time error
|
||||
-0x10000000000000004, // -(2^64+2^2) //# 268: compile-time error
|
||||
-0x10000000000000008, // -(2^64+2^3) //# 269: compile-time error
|
||||
-0x10000000000000010, // -(2^64+2^4) //# 270: compile-time error
|
||||
-0x10000000000000020, // -(2^64+2^5) //# 271: compile-time error
|
||||
-0x10000000000000040, // -(2^64+2^6) //# 272: compile-time error
|
||||
-0x10000000000000080, // -(2^64+2^7) //# 273: compile-time error
|
||||
-0x10000000000000100, // -(2^64+2^8) //# 274: compile-time error
|
||||
-0x10000000000000200, // -(2^64+2^9) //# 275: compile-time error
|
||||
-0x10000000000000400, // -(2^64+2^10) //# 276: compile-time error
|
||||
-0x10000000000000800, // -(2^64+2^11) //# 277: compile-time error
|
||||
-0xfffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, // -(maxValue - 1) //# 278 : compile-time error
|
||||
-0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001, // -(maxValue + 1) //# 279 : compile-time error
|
||||
-0x1fffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001, // -(maxValue * 2) //# 280 : compile-time error
|
||||
);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ double maxValue = 1.7976931348623157e+308;
|
||||
main() {
|
||||
expectDouble(0.0, 0);
|
||||
expectDouble(1.0, 1);
|
||||
expectDouble(0.0, 00);
|
||||
expectDouble(1.0, 01);
|
||||
expectDouble(p2_8 - 1, 255);
|
||||
expectDouble(p2_8, 256);
|
||||
expectDouble(p2_8 + 1, 257);
|
||||
@@ -55,6 +57,8 @@ main() {
|
||||
|
||||
expectDouble(-0.0, -0);
|
||||
expectDouble(-1.0, -1);
|
||||
expectDouble(-0.0, -00);
|
||||
expectDouble(-1.0, -01);
|
||||
expectDouble(-(p2_8 - 1), -255);
|
||||
expectDouble(-(p2_8), -256);
|
||||
expectDouble(-(p2_8 + 1), -257);
|
||||
@@ -84,6 +88,8 @@ main() {
|
||||
|
||||
expectDouble(0.0, 0x0);
|
||||
expectDouble(1.0, 0x1);
|
||||
expectDouble(0.0, 0x00);
|
||||
expectDouble(1.0, 0x01);
|
||||
expectDouble(p2_8 - 1, 0xff);
|
||||
expectDouble(p2_8, 0x100);
|
||||
expectDouble(p2_8 + 1, 0x101);
|
||||
@@ -113,6 +119,8 @@ main() {
|
||||
|
||||
expectDouble(-0.0, -0x0);
|
||||
expectDouble(-1.0, -0x1);
|
||||
expectDouble(-0.0, -0x00);
|
||||
expectDouble(-1.0, -0x01);
|
||||
expectDouble(-(p2_8 - 1), -0xff);
|
||||
expectDouble(-(p2_8), -0x100);
|
||||
expectDouble(-(p2_8 + 1), -0x101);
|
||||
|
||||
@@ -0,0 +1,658 @@
|
||||
// Copyright (c) 2018, 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";
|
||||
|
||||
// Check that integer literals in a double context are allowed
|
||||
// for various double context.
|
||||
|
||||
main() {
|
||||
// Variable initializer context.
|
||||
double v1 = 0;
|
||||
Expect.identical(0.0, v1);
|
||||
double v2 = 1;
|
||||
Expect.identical(1.0, v2);
|
||||
double v3 = -0;
|
||||
Expect.identical(-0.0, v3);
|
||||
double v4 = -1;
|
||||
Expect.identical(-1.0, v4);
|
||||
double v5 = 9223372036854776000; // 2^63, not valid signed 64-bit integer.
|
||||
Expect.identical(9223372036854776000.0, v5);
|
||||
double v6 = 18446744073709552000; // 2^64.
|
||||
Expect.identical(18446744073709552000.0, v6);
|
||||
double v7 = 0x02; // Hex literal.
|
||||
Expect.identical(2.0, v7);
|
||||
double v8 = -0x02; // Hex literal.
|
||||
Expect.identical(-2.0, v8);
|
||||
|
||||
// Const variable initializer context.
|
||||
const double c1 = 0;
|
||||
Expect.identical(0.0, c1);
|
||||
const double c2 = 1;
|
||||
Expect.identical(1.0, c2);
|
||||
const double c3 = -0;
|
||||
Expect.identical(-0.0, c3);
|
||||
const double c4 = -1;
|
||||
Expect.identical(-1.0, c4);
|
||||
const double c5 = 9223372036854776000;
|
||||
Expect.identical(9223372036854776000.0, c5);
|
||||
const double c6 = 18446744073709552000;
|
||||
Expect.identical(18446744073709552000.0, c6);
|
||||
const double c7 = 0x02; // Hex literal.
|
||||
Expect.identical(2.0, c7);
|
||||
const double c8 = -0x02; // Hex literal.
|
||||
Expect.identical(-2.0, c8);
|
||||
|
||||
// Assignment context, variable.
|
||||
double value;
|
||||
value = 0;
|
||||
Expect.identical(0.0, value);
|
||||
value = 1;
|
||||
Expect.identical(1.0, value);
|
||||
value = -0;
|
||||
Expect.identical(-0.0, value);
|
||||
value = -1;
|
||||
Expect.identical(-1.0, value);
|
||||
value = 9223372036854776000;
|
||||
Expect.identical(9223372036854776000.0, value);
|
||||
value = 18446744073709552000;
|
||||
Expect.identical(18446744073709552000.0, value);
|
||||
value = 0x02;
|
||||
Expect.identical(2.0, value);
|
||||
value = -0x02;
|
||||
Expect.identical(-2.0, value);
|
||||
|
||||
// Assignment context, setter.
|
||||
setter = 0;
|
||||
Expect.identical(0.0, lastSetValue);
|
||||
setter = 1;
|
||||
Expect.identical(1.0, lastSetValue);
|
||||
setter = -0;
|
||||
Expect.identical(-0.0, lastSetValue);
|
||||
setter = -1;
|
||||
Expect.identical(-1.0, lastSetValue);
|
||||
setter = 9223372036854776000;
|
||||
Expect.identical(9223372036854776000.0, lastSetValue);
|
||||
setter = 18446744073709552000;
|
||||
Expect.identical(18446744073709552000.0, lastSetValue);
|
||||
setter = 0x02;
|
||||
Expect.identical(2.0, lastSetValue);
|
||||
setter = -0x02;
|
||||
Expect.identical(-2.0, lastSetValue);
|
||||
|
||||
// Argument context.
|
||||
test(0.0, 0);
|
||||
test(1.0, 1);
|
||||
test(-0.0, -0);
|
||||
test(-1.0, -1);
|
||||
test(9223372036854776000.0, 9223372036854776000);
|
||||
test(18446744073709552000.0, 18446744073709552000);
|
||||
test(2.0, 0x02);
|
||||
test(-2.0, -0x02);
|
||||
|
||||
// Argument context, operator setter.
|
||||
List<double> box = [0.5];
|
||||
box[0] = 0;
|
||||
Expect.identical(0.0, box[0]);
|
||||
box[0] = 1;
|
||||
Expect.identical(1.0, box[0]);
|
||||
box[0] = -0;
|
||||
Expect.identical(-0.0, box[0]);
|
||||
box[0] = -1;
|
||||
Expect.identical(-1.0, box[0]);
|
||||
box[0] = 9223372036854776000;
|
||||
Expect.identical(9223372036854776000.0, box[0]);
|
||||
box[0] = 18446744073709552000;
|
||||
Expect.identical(18446744073709552000.0, box[0]);
|
||||
box[0] = 0x02;
|
||||
Expect.identical(2.0, box[0]);
|
||||
box[0] = -0x02;
|
||||
Expect.identical(-2.0, box[0]);
|
||||
|
||||
// Argument context, custom operators.
|
||||
var oper = Oper();
|
||||
Expect.identical(0.0, oper + 0);
|
||||
Expect.identical(1.0, oper + 1);
|
||||
Expect.identical(-0.0, oper + -0);
|
||||
Expect.identical(-1.0, oper + -1);
|
||||
Expect.identical(9223372036854776000.0, oper + 9223372036854776000);
|
||||
Expect.identical(18446744073709552000.0, oper + 18446744073709552000);
|
||||
Expect.identical(2.0, oper + 0x02);
|
||||
Expect.identical(-2.0, oper + -0x02);
|
||||
|
||||
Expect.identical(0.0, oper >> 0);
|
||||
Expect.identical(1.0, oper >> 1);
|
||||
Expect.identical(-0.0, oper >> -0);
|
||||
Expect.identical(-1.0, oper >> -1);
|
||||
Expect.identical(9223372036854776000.0, oper >> 9223372036854776000);
|
||||
Expect.identical(18446744073709552000.0, oper >> 18446744073709552000);
|
||||
Expect.identical(2.0, oper >> 0x02);
|
||||
Expect.identical(-2.0, oper >> -0x02);
|
||||
|
||||
Expect.identical(0.0, oper[0]);
|
||||
Expect.identical(1.0, oper[1]);
|
||||
Expect.identical(-0.0, oper[-0]);
|
||||
Expect.identical(-1.0, oper[-1]);
|
||||
Expect.identical(9223372036854776000.0, oper[9223372036854776000]);
|
||||
Expect.identical(18446744073709552000.0, oper[18446744073709552000]);
|
||||
Expect.identical(2.0, oper[0x02]);
|
||||
Expect.identical(-2.0, oper[-0x02]);
|
||||
|
||||
// Explicit return context.
|
||||
double fun1() => 0;
|
||||
Expect.identical(0.0, fun1());
|
||||
double fun2() => 1;
|
||||
Expect.identical(1.0, fun2());
|
||||
double fun3() => -0;
|
||||
Expect.identical(-0.0, fun3());
|
||||
double fun4() => -1;
|
||||
Expect.identical(-1.0, fun4());
|
||||
double fun5() => 9223372036854776000;
|
||||
Expect.identical(9223372036854776000.0, fun5());
|
||||
double fun6() => 18446744073709552000;
|
||||
Expect.identical(18446744073709552000.0, fun6());
|
||||
double fun7() => 0x02;
|
||||
Expect.identical(2.0, fun7());
|
||||
double fun4() => -0x02;
|
||||
Expect.identical(-120, fun4());
|
||||
|
||||
// Inferred return context.
|
||||
testFun(0.0, () => 0);
|
||||
testFun(1.0, () => 1);
|
||||
testFun(-0.0, () => -0);
|
||||
testFun(-1.0, () => -1);
|
||||
testFun(9223372036854776000.0, () => 9223372036854776000);
|
||||
testFun(18446744073709552000.0, () => 18446744073709552000);
|
||||
testFun(2.0, () => 0x02);
|
||||
testFun(-2.0, () => -0x02);
|
||||
|
||||
// Function default value context.
|
||||
Object deffun1([double v = 0]) => v;
|
||||
Expect.identical(0.0, deffun1());
|
||||
Object deffun2([double v = 1]) => v;
|
||||
Expect.identical(1.0, deffun2());
|
||||
Object deffun3([double v = -0]) => v;
|
||||
Expect.identical(-0.0, deffun3());
|
||||
Object deffun4([double v = -1]) => v;
|
||||
Expect.identical(-1.0, deffun4());
|
||||
Object deffun5([double v = 9223372036854776000]) => v;
|
||||
Expect.identical(9223372036854776000.0, deffun5());
|
||||
Object deffun6([double v = 18446744073709552000]) => v;
|
||||
Expect.identical(18446744073709552000.0, deffun6());
|
||||
Object deffun7([double v = 0x02]) => v;
|
||||
Expect.identical(2.0, deffun7());
|
||||
Object deffun8([double v = -0x02]) => v;
|
||||
Expect.identical(-2.0, deffun8());
|
||||
|
||||
// Explicit collection literal context.
|
||||
box = <double>[0];
|
||||
Expect.identical(0.0, box[0]);
|
||||
box = <double>[1];
|
||||
Expect.identical(1.0, box[0]);
|
||||
box = <double>[-0];
|
||||
Expect.identical(-0.0, box[0]);
|
||||
box = <double>[-1];
|
||||
Expect.identical(-1.0, box[0]);
|
||||
box = <double>[9223372036854776000];
|
||||
Expect.identical(9223372036854776000.0, box[0]);
|
||||
box = <double>[18446744073709552000];
|
||||
Expect.identical(18446744073709552000.0, box[0]);
|
||||
box = <double>[0x02];
|
||||
Expect.identical(2.0, box[0]);
|
||||
box = <double>[-0x02];
|
||||
Expect.identical(-2.0, box[0]);
|
||||
|
||||
// Implicit collection literal context.
|
||||
box = [0];
|
||||
Expect.identical(0.0, box[0]);
|
||||
box = [1];
|
||||
Expect.identical(1.0, box[0]);
|
||||
box = [-0];
|
||||
Expect.identical(-0.0, box[0]);
|
||||
box = [-1];
|
||||
Expect.identical(-1.0, box[0]);
|
||||
box = [9223372036854776000];
|
||||
Expect.identical(9223372036854776000.0, box[0]);
|
||||
box = [18446744073709552000];
|
||||
Expect.identical(18446744073709552000.0, box[0]);
|
||||
box = [0x02];
|
||||
Expect.identical(2.0, box[0]);
|
||||
box = [-0x02];
|
||||
Expect.identical(-2.0, box[0]);
|
||||
|
||||
Map<double, double> map;
|
||||
// Explicit map key context.
|
||||
map = <double, Null>{0: null};
|
||||
Expect.identical(0.0, map.keys.first);
|
||||
map = <double, Null>{1: null};
|
||||
Expect.identical(1.0, map.keys.first);
|
||||
map = <double, Null>{-0: null};
|
||||
Expect.identical(-0.0, map.keys.first);
|
||||
map = <double, Null>{-1: null};
|
||||
Expect.identical(-1.0, map.keys.first);
|
||||
map = <double, Null>{9223372036854776000: null};
|
||||
Expect.identical(9223372036854776000.0, map.keys.first);
|
||||
map = <double, Null>{18446744073709552000: null};
|
||||
Expect.identical(18446744073709552000.0, map.keys.first);
|
||||
map = <double, Null>{0x02: null};
|
||||
Expect.identical(2.0, map.keys.first);
|
||||
map = <double, Null>{-0x02: null};
|
||||
Expect.identical(-2.0, map.keys.first);
|
||||
|
||||
// Implicit map key context.
|
||||
map = {0: null};
|
||||
Expect.identical(0.0, map.keys.first);
|
||||
map = {1: null};
|
||||
Expect.identical(1.0, map.keys.first);
|
||||
map = {-0: null};
|
||||
Expect.identical(-0.0, map.keys.first);
|
||||
map = {-1: null};
|
||||
Expect.identical(-1.0, map.keys.first);
|
||||
map = {9223372036854776000: null};
|
||||
Expect.identical(9223372036854776000.0, map.keys.first);
|
||||
map = {18446744073709552000: null};
|
||||
Expect.identical(18446744073709552000.0, map.keys.first);
|
||||
map = {0x02: null};
|
||||
Expect.identical(2.0, map.keys.first);
|
||||
map = {-0x02: null};
|
||||
Expect.identical(-2.0, map.keys.first);
|
||||
|
||||
// Explicit map value context.
|
||||
map = <Null, double>{null: 0};
|
||||
Expect.identical(0.0, map.values.first);
|
||||
map = <Null, double>{null: 1};
|
||||
Expect.identical(1.0, map.values.first);
|
||||
map = <Null, double>{null: -0};
|
||||
Expect.identical(-0.0, map.values.first);
|
||||
map = <Null, double>{null: -1};
|
||||
Expect.identical(-1.0, map.values.first);
|
||||
map = <Null, double>{null: 9223372036854776000};
|
||||
Expect.identical(9223372036854776000.0, map.values.first);
|
||||
map = <Null, double>{null: 18446744073709552000};
|
||||
Expect.identical(18446744073709552000.0, map.values.first);
|
||||
map = <Null, double>{null: 0x02};
|
||||
Expect.identical(2.0, map.values.first);
|
||||
map = <Null, double>{null: -0x02};
|
||||
Expect.identical(-2.0, map.values.first);
|
||||
|
||||
// Implicit map value context.
|
||||
map = {null: 0};
|
||||
Expect.identical(0.0, map.values.first);
|
||||
map = {null: 1};
|
||||
Expect.identical(1.0, map.values.first);
|
||||
map = {null: -0};
|
||||
Expect.identical(-0.0, map.values.first);
|
||||
map = {null: -1};
|
||||
Expect.identical(-1.0, map.values.first);
|
||||
map = {null: 9223372036854776000};
|
||||
Expect.identical(9223372036854776000.0, map.values.first);
|
||||
map = {null: 18446744073709552000};
|
||||
Expect.identical(18446744073709552000.0, map.values.first);
|
||||
map = {null: 0x02};
|
||||
Expect.identical(2.0, map.values.first);
|
||||
map = {null: -0x02};
|
||||
Expect.identical(-2.0, map.values.first);
|
||||
|
||||
// Top-level contexts
|
||||
Expect.identical(0.0, ts1);
|
||||
Expect.identical(1.0, ts2);
|
||||
Expect.identical(-0.0, ts3);
|
||||
Expect.identical(-1.0, ts4);
|
||||
Expect.identical(9223372036854776000.0, ts5);
|
||||
Expect.identical(18446744073709552000.0, ts6);
|
||||
Expect.identical(2.0, ts7);
|
||||
Expect.identical(-2.0, ts8);
|
||||
|
||||
Expect.identical(0.0, tc1);
|
||||
Expect.identical(1.0, tc2);
|
||||
Expect.identical(-0.0, tc3);
|
||||
Expect.identical(-1.0, tc4);
|
||||
Expect.identical(9223372036854776000.0, tc5);
|
||||
Expect.identical(18446744073709552000.0, tc6);
|
||||
Expect.identical(2.0, tc7);
|
||||
Expect.identical(-2.0, tc8);
|
||||
|
||||
Expect.identical(0.0, tg1);
|
||||
Expect.identical(1.0, tg2);
|
||||
Expect.identical(-0.0, tg3);
|
||||
Expect.identical(-1.0, tg4);
|
||||
Expect.identical(9223372036854776000.0, tg5);
|
||||
Expect.identical(18446744073709552000.0, tg6);
|
||||
Expect.identical(2.0, tg7);
|
||||
Expect.identical(-2.0, tg8);
|
||||
|
||||
// Class contexts
|
||||
var c = new C();
|
||||
Expect.identical(0.0, c.v1);
|
||||
Expect.identical(1.0, c.v2);
|
||||
Expect.identical(-0.0, c.v3);
|
||||
Expect.identical(-1.0, c.v4);
|
||||
Expect.identical(9223372036854776000.0, c.v5);
|
||||
Expect.identical(18446744073709552000.0, c.v6);
|
||||
Expect.identical(2.0, c.v7);
|
||||
Expect.identical(-2.0, c.v8);
|
||||
|
||||
Expect.identical(0.0, C.s1);
|
||||
Expect.identical(1.0, C.s2);
|
||||
Expect.identical(-0.0, C.s3);
|
||||
Expect.identical(-1.0, C.s4);
|
||||
Expect.identical(9223372036854776000.0, C.s5);
|
||||
Expect.identical(18446744073709552000.0, C.s6);
|
||||
Expect.identical(2.0, C.s7);
|
||||
Expect.identical(-2.0, C.s8);
|
||||
|
||||
Expect.identical(0.0, C.c1);
|
||||
Expect.identical(1.0, C.c2);
|
||||
Expect.identical(-0.0, C.c3);
|
||||
Expect.identical(-1.0, C.c4);
|
||||
Expect.identical(9223372036854776000.0, C.c5);
|
||||
Expect.identical(18446744073709552000.0, C.c6);
|
||||
Expect.identical(2.0, C.c7);
|
||||
Expect.identical(-2.0, C.c8);
|
||||
|
||||
Expect.identical(0.0, new C.cc1().d);
|
||||
Expect.identical(1.0, new C.cc2().d);
|
||||
Expect.identical(-0.0, new C.cc3().d);
|
||||
Expect.identical(-1.0, new C.cc4().d);
|
||||
Expect.identical(9223372036854776000.0, new C.cc5().d);
|
||||
Expect.identical(18446744073709552000.0, new C.cc6().d);
|
||||
Expect.identical(2.0, new C.cc7().d);
|
||||
Expect.identical(-2.0, new C.cc8().d);
|
||||
|
||||
Expect.identical(0.0, const C.cc1().d);
|
||||
Expect.identical(1.0, const C.cc2().d);
|
||||
Expect.identical(-0.0, const C.cc3().d);
|
||||
Expect.identical(-1.0, const C.cc4().d);
|
||||
Expect.identical(9223372036854776000.0, const C.cc5().d);
|
||||
Expect.identical(18446744073709552000.0, const C.cc6().d);
|
||||
Expect.identical(2.0, const C.cc7().d);
|
||||
Expect.identical(-2.0, const C.cc8().d);
|
||||
|
||||
Expect.identical(0.0, new C.ci1().d);
|
||||
Expect.identical(1.0, new C.ci2().d);
|
||||
Expect.identical(-0.0, new C.ci3().d);
|
||||
Expect.identical(-1.0, new C.ci4().d);
|
||||
Expect.identical(9223372036854776000.0, new C.ci5().d);
|
||||
Expect.identical(18446744073709552000.0, new C.ci6().d);
|
||||
Expect.identical(2.0, new C.ci7().d);
|
||||
Expect.identical(-2.0, new C.ci8().d);
|
||||
|
||||
Expect.identical(0.0, const C.ci1().d);
|
||||
Expect.identical(1.0, const C.ci2().d);
|
||||
Expect.identical(-0.0, const C.ci3().d);
|
||||
Expect.identical(-1.0, const C.ci4().d);
|
||||
Expect.identical(9223372036854776000.0, const C.ci5().d);
|
||||
Expect.identical(18446744073709552000.0, const C.ci6().d);
|
||||
Expect.identical(2.0, const C.ci7().d);
|
||||
Expect.identical(-2.0, const C.ci8().d);
|
||||
|
||||
// Nested context, `?:`.
|
||||
v1 = false ? 42.0 : 0;
|
||||
Expect.identical(0.0, v1);
|
||||
v2 = false ? 42.0 : 1;
|
||||
Expect.identical(1.0, v2);
|
||||
v3 = false ? 42.0 : -0;
|
||||
Expect.identical(-0.0, v3);
|
||||
v4 = false ? 42.0 : -1;
|
||||
Expect.identical(-1.0, v4);
|
||||
v5 = false ? 42.0 : 9223372036854776000;
|
||||
Expect.identical(9223372036854776000.0, v5);
|
||||
v6 = false ? 42.0 : 18446744073709552000;
|
||||
Expect.identical(18446744073709552000.0, v6);
|
||||
v7 = false ? 42.0 : 0x02; // Hex literal.
|
||||
Expect.identical(2.0, v7);
|
||||
v8 = false ? 42.0 : -0x02; // Hex literal.
|
||||
Expect.identical(-2.0, v8);
|
||||
|
||||
// Nested context, `??`.
|
||||
double nl = double.tryParse("not a double"); // Returns null typed as double.
|
||||
v1 = nl ?? 0;
|
||||
Expect.identical(0.0, v1);
|
||||
v2 = nl ?? 1;
|
||||
Expect.identical(1.0, v2);
|
||||
v3 = nl ?? -0;
|
||||
Expect.identical(-0.0, v3);
|
||||
v4 = nl ?? -1;
|
||||
Expect.identical(-1.0, v4);
|
||||
v5 = nl ?? 9223372036854776000;
|
||||
Expect.identical(9223372036854776000.0, v5);
|
||||
v6 = nl ?? 18446744073709552000;
|
||||
Expect.identical(18446744073709552000.0, v6);
|
||||
v7 = nl ?? 0x02; // Hex literal.
|
||||
Expect.identical(2.0, v7);
|
||||
v8 = nl ?? -0x02; // Hex literal.
|
||||
Expect.identical(-2.0, v8);
|
||||
|
||||
// Nested context, `..`.
|
||||
v1 = 0..toString();
|
||||
Expect.identical(0.0, v1);
|
||||
v2 = 1..toString();
|
||||
Expect.identical(1.0, v2);
|
||||
v3 = -0
|
||||
..toString();
|
||||
Expect.identical(-0.0, v3);
|
||||
v4 = -1
|
||||
..toString();
|
||||
Expect.identical(-1.0, v4);
|
||||
v5 = 9223372036854776000..toString();
|
||||
Expect.identical(9223372036854776000.0, v5);
|
||||
v6 = 18446744073709552000..toString();
|
||||
Expect.identical(18446744073709552000.0, v6);
|
||||
v7 = 0x02..toString(); // Hex literal.
|
||||
Expect.identical(2.0, v7);
|
||||
v8 = -0x02
|
||||
..toString(); // Hex literal.
|
||||
Expect.identical(-2.0, v8);
|
||||
|
||||
// Nexted context, double assignment.
|
||||
Object object;
|
||||
object = value = 0;
|
||||
Expect.identical(0.0, value);
|
||||
object = value = 1;
|
||||
Expect.identical(1.0, value);
|
||||
object = value = -0;
|
||||
Expect.identical(-0.0, value);
|
||||
object = value = -1;
|
||||
Expect.identical(-1.0, value);
|
||||
object = value = 9223372036854776000;
|
||||
Expect.identical(9223372036854776000.0, value);
|
||||
object = value = 18446744073709552000;
|
||||
Expect.identical(18446744073709552000.0, value);
|
||||
object = value = 0x02;
|
||||
Expect.identical(2.0, value);
|
||||
object = value = -0x02;
|
||||
Expect.identical(-2.0, value);
|
||||
|
||||
// Nested context, value of assignment.
|
||||
Expect.identical(0.0, value = 0);
|
||||
Expect.identical(1.0, value = 1);
|
||||
Expect.identical(-0.0, value = -0);
|
||||
Expect.identical(-1.0, value = -1);
|
||||
Expect.identical(9223372036854776000.0, value = 9223372036854776000);
|
||||
Expect.identical(18446744073709552000.0, value = 18446744073709552000);
|
||||
Expect.identical(2.0, value = 0x02);
|
||||
Expect.identical(-2.0, value = -0x02);
|
||||
|
||||
// Not promoted without a double context.
|
||||
num x = -0;
|
||||
Expect.identical(0, x);
|
||||
Expect.isFalse(x.isNegative);
|
||||
|
||||
var list = [3.14, 2.17, -0];
|
||||
Expect.notType<List<double>>(list);
|
||||
Expect.identical(0, list[2]);
|
||||
Expect.isFalse(list[2].isNegative);
|
||||
|
||||
// FutureOr<double> also forces double.
|
||||
// "Type that int is not assignable to, but double is."
|
||||
FutureOr<double> fo1 = 0;
|
||||
Expect.identical(0.0, fo1);
|
||||
FutureOr<double> fo2 = 1;
|
||||
Expect.identical(1.0, fo2);
|
||||
FutureOr<double> fo3 = -0;
|
||||
Expect.identical(-0.0, fo3);
|
||||
FutureOr<double> fo4 = -1;
|
||||
Expect.identical(-1.0, fo4);
|
||||
FutureOr<double> fo5 = 9223372036854776000;
|
||||
Expect.identical(9223372036854776000.0, fo5);
|
||||
FutureOr<double> fo6 = 18446744073709552000;
|
||||
Expect.identical(18446744073709552000.0, fo6);
|
||||
FutureOr<double> fo7 = 0x02; // Hex literal.
|
||||
Expect.identical(2.0, fo7);
|
||||
FutureOr<double> fo8 = -0x02; // Hex literal.
|
||||
Expect.identical(-2.0, fo8);
|
||||
|
||||
// Some other FutureOr cases, without being exhaustive.
|
||||
{
|
||||
Object func([FutureOr<double> x = 9223372036854776000]) => x;
|
||||
Expect.identical(9223372036854776000.0, func(9223372036854776000));
|
||||
Expect.identical(9223372036854776000.0, func());
|
||||
FutureOr<double> func2() => 9223372036854776000;
|
||||
Expect.identical(9223372036854776000.0, func2());
|
||||
testGeneric<FutureOr<double>>(9223372036854776000.0, 9223372036854776000);
|
||||
List<FutureOr<double>> l = [9223372036854776000];
|
||||
testGeneric<FutureOr<double>>(9223372036854776000.0, l[0]);
|
||||
l.add(9223372036854776000);
|
||||
testGeneric<FutureOr<double>>(9223372036854776000.0, l[1]);
|
||||
l.add(0.0);
|
||||
l[2] = 9223372036854776000;
|
||||
testGeneric<FutureOr<double>>(9223372036854776000.0, l[2]);
|
||||
}
|
||||
|
||||
// Type variables statically bound to double also force doubles:
|
||||
testGeneric<double>(0.0, 0);
|
||||
testGeneric<double>(1.0, 1);
|
||||
testGeneric<double>(-0.0, -0);
|
||||
testGeneric<double>(-1.0, -1);
|
||||
testGeneric<double>(9223372036854776000.0, 9223372036854776000);
|
||||
testGeneric<double>(18446744073709552000.0, 18446744073709552000);
|
||||
testGeneric<double>(2.0, 0x02);
|
||||
testGeneric<double>(-2.0, -0x02);
|
||||
|
||||
// Uses static type, not run-time type.
|
||||
Super sub = Sub();
|
||||
Expect.identical(0.0, sub.method(0));
|
||||
Expect.identical(1.0, sub.method(1));
|
||||
Expect.identical(-0.0, sub.method(-0));
|
||||
Expect.identical(-1.0, sub.method(-1));
|
||||
Expect.identical(9223372036854776000.0, sub.method(9223372036854776000));
|
||||
Expect.identical(18446744073709552000.0, sub.method(18446744073709552000));
|
||||
Expect.identical(2.0, sub.method(0x02));
|
||||
Expect.identical(-2.0, sub.method(-0x02));
|
||||
}
|
||||
|
||||
void test(double expect, double value) {
|
||||
Expect.identical(expect, value);
|
||||
}
|
||||
|
||||
void testFun(double expect, double f()) {
|
||||
Expect.identical(expect, f());
|
||||
}
|
||||
|
||||
void testGeneric<T>(double expect, T value) {
|
||||
Expect.identical(expect, value);
|
||||
}
|
||||
|
||||
class Oper {
|
||||
Object operator +(double value) => value;
|
||||
Object operator >>(double value) => value;
|
||||
Object operator [](double value) => value;
|
||||
}
|
||||
|
||||
class C {
|
||||
// Instance variable initializer
|
||||
final double v1 = 0;
|
||||
final double v2 = 1;
|
||||
final double v3 = -0;
|
||||
final double v4 = -1;
|
||||
final double v5 = 9223372036854776000;
|
||||
final double v6 = 18446744073709552000;
|
||||
final double v7 = 0x02; // Hex literal.
|
||||
final double v8 = -0x02; // Hex literal.
|
||||
|
||||
// Static class variable initializer
|
||||
static double s1 = 0;
|
||||
static double s2 = 1;
|
||||
static double s3 = -0;
|
||||
static double s4 = -1;
|
||||
static double s5 = 9223372036854776000;
|
||||
static double s6 = 18446744073709552000;
|
||||
static double s7 = 0x02; // Hex literal.
|
||||
static double s8 = -0x02; // Hex literal.
|
||||
|
||||
// Const class variable initializer context.
|
||||
static const double c1 = 0;
|
||||
static const double c2 = 1;
|
||||
static const double c3 = -0;
|
||||
static const double c4 = -1;
|
||||
static const double c5 = 9223372036854776000;
|
||||
static const double c6 = 18446744073709552000;
|
||||
static const double c7 = 0x02; // Hex literal.
|
||||
static const double c8 = -0x02; // Hex literal.
|
||||
|
||||
final double d;
|
||||
|
||||
// Default value context for a double initializing formal.
|
||||
const C.cc1([this.d = 0]);
|
||||
const C.cc2([this.d = 1]);
|
||||
const C.cc3([this.d = -0]);
|
||||
const C.cc4([this.d = -1]);
|
||||
const C.cc5([this.d = 9223372036854776000]);
|
||||
const C.cc6([this.d = 18446744073709552000]);
|
||||
const C.cc7([this.d = 0x02]);
|
||||
const C.cc8([this.d = -0x02]);
|
||||
|
||||
// Initializer list expressions context.
|
||||
const C.ci1() : this.d = 0;
|
||||
const C.ci2() : this.d = 1;
|
||||
const C.ci3() : this.d = -0;
|
||||
const C.ci4() : this.d = -1;
|
||||
const C.ci5() : this.d = 9223372036854776000;
|
||||
const C.ci6() : this.d = 18446744073709552000;
|
||||
const C.ci7() : this.d = 0x02;
|
||||
const C.ci8() : this.d = -0x02;
|
||||
}
|
||||
|
||||
// Top-level lazy variable initializer
|
||||
double ts1 = 0;
|
||||
double ts2 = 1;
|
||||
double ts3 = -0;
|
||||
double ts4 = -1;
|
||||
double ts5 = 9223372036854776000;
|
||||
double ts6 = 18446744073709552000;
|
||||
double ts7 = 0x02; // Hex literal.
|
||||
double ts8 = -0x02; // Hex literal.
|
||||
|
||||
// Top-level const variable initializer.
|
||||
const double tc1 = 0;
|
||||
const double tc2 = 1;
|
||||
const double tc3 = -0;
|
||||
const double tc4 = -1;
|
||||
const double tc5 = 9223372036854776000; // 2^63, invalid signed 64-bit integer.
|
||||
const double tc6 = 18446744073709552000;
|
||||
const double tc7 = 0x02; // Hex literal.
|
||||
const double tc8 = -0x02; // Hex literal.
|
||||
|
||||
// Top-level getter return context.
|
||||
double get tg1 => 0;
|
||||
double get tg2 => 1;
|
||||
double get tg3 => -0;
|
||||
double get tg4 => -1;
|
||||
double get tg5 => 9223372036854776000;
|
||||
double get tg6 => 18446744073709552000;
|
||||
double get tg7 => 0x02; // Hex literal.
|
||||
double get tg8 => -0x02; // Hex literal.
|
||||
|
||||
Object lastSetValue = null;
|
||||
void set setter(double v) {
|
||||
lastSetValue = v;
|
||||
}
|
||||
|
||||
abstract class Super {
|
||||
Object method(double v);
|
||||
}
|
||||
|
||||
class Sub implements Super {
|
||||
Object method(Object o) => o;
|
||||
}
|
||||
Reference in New Issue
Block a user