Fix web_int_literals_test.dart.

This test was inadvertently broken when automatically migrated from a
multitest to a static error test.

The original intent of the test was to ensure that web compilers
reported compile-time errors on integer literals that couldn't be
represented as JS doubles. The migrated static error test doesn't have
any web expectations and thus doesn't get run on web compilers at all.
Instead, all it does is validate that the one non-web error in there is
reported.

This turns the test into a proper *web* static error test with the
web-specific test expectations in there. That ensures the test is run
on web compilers and validates that the web compilers produce those
expected errors.

Also removed the corresponding runtime test since it doesn't do
anything. There's no runtime behavior to test, and the static error
test also correctly validates that the *valid* integer literals do *not*
produce compile errors.

Removed the status file entries because they're no longer needed. Since
this is a static error test, the runtime platforms already skip it
implicitly.

Change-Id: I2776847e1acb88b1f761efb43e7bb528b27d0eee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297840
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
This commit is contained in:
Robert Nystrom 2023-04-25 21:28:39 +00:00 committed by Commit Queue
parent 80d26df2fd
commit 4bfb196287
4 changed files with 54 additions and 76 deletions

View file

@ -4,6 +4,7 @@
# Sections in this file should contain "$compiler == dart2wasm".
[ $compiler == dart2wasm ]
number/web_int_literals_test: SkipByDesign # WASM has real integers.
vm/*: SkipByDesign # Tests for the VM.
[ $compiler == dart2wasm && $runtime == d8 ]

View file

@ -4,17 +4,12 @@
[ $compiler == app_jitk ]
main/no_main_test/01: Crash
number/web_int_literals_test/*: SkipByDesign # Test applies only to JavaScript targets
unsorted/disassemble_test: SkipByDesign # Tested in JIT mode.
vm/regress_27671_test: SkipByDesign # Relies on string comparison of exception message which may return '<optimized out>'
[ $compiler == dartkp ]
number/web_int_literals_test/*: SkipByDesign # Test applies only to JavaScript targets
unsorted/disassemble_test: SkipByDesign # JIT only test
[ $compiler == fasta ]
number/web_int_literals_test/*: SkipByDesign # Test applies only to JavaScript targets
[ $arch == ia32 && $mode == debug ]
*: Pass, Slow # The CFE is not run from AppJit snapshot, JIT warmup in debug mode very slow
@ -56,7 +51,6 @@ mixin/illegal_superclass_test: Skip # Issues 24478 and 23773
unsorted/disassemble_test: Slow, Crash # dartbug.com/34971
vm/closure_memory_retention_test: Skip # KernelVM bug: Hits OOM
vm/regress_29145_test: Skip # Issue 29145
web_int_literals_test/*: SkipByDesign # Test applies only to JavaScript targets
[ $compiler == dartk && $hot_reload_rollback ]
symbol/conflict_test: Slow, Pass

View file

@ -1,69 +0,0 @@
// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.
// 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";
main() {
check(0x8000000000000000);
check(0x7FFF00001111F000);
check(0x7FFF00001111FC00);
check(0xFFFF00001111F000);
check(0xFFFF00001111F800);
// Test all runs of 53 and 54 bits.
check(0x000FFFFFFFFFFFFF);
check(0x001FFFFFFFFFFFFF);
check(0x003FFFFFFFFFFFFE);
check(0x007FFFFFFFFFFFFC);
check(0x00FFFFFFFFFFFFF8);
check(0x01FFFFFFFFFFFFF0);
check(0x03FFFFFFFFFFFFE0);
check(0x07FFFFFFFFFFFFC0);
check(0x0FFFFFFFFFFFFF80);
check(0x1FFFFFFFFFFFFF00);
check(0x3FFFFFFFFFFFFE00);
check(0x7FFFFFFFFFFFFC00);
check(0xFFFFFFFFFFFFF800);
// Too big, even on VM.
// 9223372036854775808 - 512 is rounded.
// 9223372036854775808 - 1024 is exact.
check(9223372036854774784);
check(-9223372036854775808);
check(-9223372036854774784);
}
check(int n) {}

View file

@ -2,7 +2,8 @@
// 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";
// Integer literals that lose precision when represented as a JavaScript double
// are compile errors in the web compilers.
main() {
check(0x8000000000000000);
@ -10,40 +11,76 @@ main() {
check(0x7FFF00001111F000);
check(0x7FFF00001111FC00);
check(0x7FFF00001111FE00);
// ^
// [web] The integer literal 0x7FFF00001111FE00 can't be represented exactly in JavaScript.
check(0x7FFF00001111FF00);
// ^
// [web] The integer literal 0x7FFF00001111FF00 can't be represented exactly in JavaScript.
check(0x7FFF00001111FFFF);
// ^
// [web] The integer literal 0x7FFF00001111FFFF can't be represented exactly in JavaScript.
check(0xFFFF00001111F000);
check(0xFFFF00001111F800);
check(0xFFFF00001111FC00);
// ^
// [web] The integer literal 0xFFFF00001111FC00 can't be represented exactly in JavaScript.
check(0xFFFF00001111FE00);
// ^
// [web] The integer literal 0xFFFF00001111FE00 can't be represented exactly in JavaScript.
check(0xFFFF00001111FF00);
// ^
// [web] The integer literal 0xFFFF00001111FF00 can't be represented exactly in JavaScript.
check(0xFFFF00001111FFFF);
// ^
// [web] The integer literal 0xFFFF00001111FFFF can't be represented exactly in JavaScript.
// Test all runs of 53 and 54 bits.
check(0x000FFFFFFFFFFFFF);
check(0x001FFFFFFFFFFFFF);
check(0x003FFFFFFFFFFFFF);
// ^
// [web] The integer literal 0x003FFFFFFFFFFFFF can't be represented exactly in JavaScript.
check(0x003FFFFFFFFFFFFE);
check(0x007FFFFFFFFFFFFE);
// ^
// [web] The integer literal 0x007FFFFFFFFFFFFE can't be represented exactly in JavaScript.
check(0x007FFFFFFFFFFFFC);
check(0x00FFFFFFFFFFFFFC);
// ^
// [web] The integer literal 0x00FFFFFFFFFFFFFC can't be represented exactly in JavaScript.
check(0x00FFFFFFFFFFFFF8);
check(0x01FFFFFFFFFFFFF8);
// ^
// [web] The integer literal 0x01FFFFFFFFFFFFF8 can't be represented exactly in JavaScript.
check(0x01FFFFFFFFFFFFF0);
check(0x03FFFFFFFFFFFFF0);
// ^
// [web] The integer literal 0x03FFFFFFFFFFFFF0 can't be represented exactly in JavaScript.
check(0x03FFFFFFFFFFFFE0);
check(0x07FFFFFFFFFFFFE0);
// ^
// [web] The integer literal 0x07FFFFFFFFFFFFE0 can't be represented exactly in JavaScript.
check(0x07FFFFFFFFFFFFC0);
check(0x0FFFFFFFFFFFFFC0);
// ^
// [web] The integer literal 0x0FFFFFFFFFFFFFC0 can't be represented exactly in JavaScript.
check(0x0FFFFFFFFFFFFF80);
check(0x1FFFFFFFFFFFFF80);
// ^
// [web] The integer literal 0x1FFFFFFFFFFFFF80 can't be represented exactly in JavaScript.
check(0x1FFFFFFFFFFFFF00);
check(0x3FFFFFFFFFFFFF00);
// ^
// [web] The integer literal 0x3FFFFFFFFFFFFF00 can't be represented exactly in JavaScript.
check(0x3FFFFFFFFFFFFE00);
check(0x7FFFFFFFFFFFFE00);
// ^
// [web] The integer literal 0x7FFFFFFFFFFFFE00 can't be represented exactly in JavaScript.
check(0x7FFFFFFFFFFFFC00);
check(0xFFFFFFFFFFFFFC00);
// ^
// [web] The integer literal 0xFFFFFFFFFFFFFC00 can't be represented exactly in JavaScript.
check(0xFFFFFFFFFFFFF800);
// Too big, even on VM.
@ -51,19 +88,34 @@ main() {
// ^^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.INTEGER_LITERAL_OUT_OF_RANGE
// [cfe] The integer literal 9223372036854775808 can't be represented in 64 bits.
// [web] The integer literal 9223372036854775808 can't be represented in 64 bits.
check(9223372036854775807);
// ^
// [web] The integer literal 9223372036854775807 can't be represented exactly in JavaScript.
check(9223372036854775806);
// ^
// [web] The integer literal 9223372036854775806 can't be represented exactly in JavaScript.
// 9223372036854775808 - 512 is rounded.
check(9223372036854775296);
// ^
// [web] The integer literal 9223372036854775296 can't be represented exactly in JavaScript.
// 9223372036854775808 - 1024 is exact.
check(9223372036854774784);
check(-9223372036854775808);
check(-9223372036854775807);
// ^
// [web] The integer literal 9223372036854775807 can't be represented exactly in JavaScript.
check(-9223372036854775296);
// ^
// [web] The integer literal 9223372036854775296 can't be represented exactly in JavaScript.
check(-9223372036854774784);
check(1000000000000000001);
// ^
// [web] The integer literal 1000000000000000001 can't be represented exactly in JavaScript.
}
check(int n) {}