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
37 lines
1.2 KiB
Dart
37 lines
1.2 KiB
Dart
// 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";
|
|
|
|
// Make sure we use JavaScript semantics when compiling compile-time constants.
|
|
|
|
const x = 12345678901234567891;
|
|
const y = 12345678901234567890;
|
|
const z = x - y;
|
|
|
|
const a = 1.0;
|
|
const b = a << 3; // This would not be valid with Dart semantics.
|
|
|
|
const c = -0.0;
|
|
const d = c << 1; // This would not be valid with Dart semantics.
|
|
|
|
foo() => 12345678901234567891 - 12345678901234567890;
|
|
|
|
main() {
|
|
Expect.equals(0, z);
|
|
Expect.equals(0, x - y);
|
|
Expect.equals(0, foo());
|
|
Expect.isTrue(x is double);
|
|
Expect.isTrue(x is int);
|
|
Expect.equals(8, b);
|
|
Expect.equals(8, 1.0 << 3); // This would not be valid with Dart semantics.
|
|
Expect.isTrue(1 == 1.0);
|
|
Expect.equals(0, d);
|
|
Expect.equals(0, -0.0 << 1); // This would not be valid with Dart semantics.
|
|
// Make sure the 1 is not shifted into the 32 bit range.
|
|
Expect.equals(0, 0x100000000 >> 3);
|
|
// The dynamic int-check also allows -0.0.
|
|
Expect.isTrue((-0.0) is int);
|
|
}
|