8fd6d0aafd
Committed: https://code.google.com/p/dart/source/detail?r=19755 Reverted: http://code.google.com/p/dart/source/detail?r=19756 Review URL: https://codereview.chromium.org//12212016 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@20996 260f80e4-7a28-3924-810f-c04153c831b5
60 lines
1.8 KiB
Dart
60 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();
|
|
}
|