Files
sdk/tests/language_2/number/syntax_test.dart
T
Robert Nystrom fc1b1ecc71 Move files under language_2 into subdirectories.
Change-Id: Idbcc965a27e9ffeedf5e0a1068b019de4193070f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127745
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2019-12-11 19:18:00 +00:00

59 lines
1.8 KiB
Dart

// Copyright (c) 2011, 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";
class NumberSyntaxTest {
static void testMain() {
testShortDoubleSyntax();
testDotSelectorSyntax();
}
static void testShortDoubleSyntax() {
Expect.equals(0.0, .0);
Expect.equals(0.5, .5);
Expect.equals(0.1234, .1234);
}
static void testDotSelectorSyntax() {
// Integers.
Expect.equals('0', 0.toString());
Expect.equals('1', 1.toString());
Expect.equals('123', 123.toString());
Expect.equals('0', 0.toString());
Expect.equals('1', 1.toString());
Expect.equals('123', 123.toString());
Expect.equals('0', 0.toString());
Expect.equals('1', 1.toString());
Expect.equals('123', 123.toString());
// Doubles.
Expect.equals((0.0).toString(), 0.0.toString());
Expect.equals((0.1).toString(), .1.toString());
Expect.equals((1.1).toString(), 1.1.toString());
Expect.equals((123.4).toString(), 123.4.toString());
Expect.equals((0.0).toString(), 0.0.toString());
Expect.equals((0.1).toString(), .1.toString());
Expect.equals((1.1).toString(), 1.1.toString());
Expect.equals((123.4).toString(), 123.4.toString());
Expect.equals((0.0).toString(), 0.0.toString());
Expect.equals((0.1).toString(), .1.toString());
Expect.equals((1.1).toString(), 1.1.toString());
Expect.equals((123.4).toString(), 123.4.toString());
// Exponent notation.
Expect.equals((0e0).toString(), 0e0.toString());
Expect.equals((1e+1).toString(), 1e+1.toString());
Expect.equals((2.1e-34).toString(), 2.1e-34.toString());
}
}
main() {
NumberSyntaxTest.testMain();
}