Skip to content

Commit

Permalink
#1024. Tests that plays with the integers not representable in JS mov…
Browse files Browse the repository at this point in the history
…ed to separate files. These files will be skipped on JS
  • Loading branch information
sgrekhov committed Mar 19, 2021
1 parent 1abf208 commit 2a09bd3
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 18 deletions.
15 changes: 7 additions & 8 deletions Language/Expressions/Shift/integer_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,18 @@ main() {
Expect.equals(16, i << 4);
Expect.equals(32, i << 5);
Expect.equals(64, i << 6);
Expect.equals(-9223372036854775808, i << 63);

Expect.equals(0, i << 64);
Expect.equals(0, i << 65);
Expect.equals(0, i << 100);

int j = 0x7FFFFFFFFFFFFFFF;
Expect.equals(-2, j << 1);
Expect.equals(-4, j << 2);
Expect.equals(-8, j << 3);
Expect.equals(-16, j << 4);
Expect.equals(-32, j << 5);
Expect.equals(-64, j << 6);
int j = 0x7FFFFFFFFFFFF000;
Expect.equals(-8192, j << 1);
Expect.equals(-16384, j << 2);
Expect.equals(-32768, j << 3);
Expect.equals(-65536, j << 4);
Expect.equals(-131072, j << 5);
Expect.equals(-262144, j << 6);
Expect.equals(0, j << 64);
Expect.equals(0, j << 65);
Expect.equals(0, j << 100);
Expand Down
8 changes: 4 additions & 4 deletions Language/Expressions/Shift/integer_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ main() {
Expect.equals(0, i >> 64);
Expect.equals(0, i >> 100);

int j = 0x7FFFFFFFFFFFFFFF;
Expect.equals(4611686018427387903, j >> 1);
Expect.equals(2305843009213693951, j >> 2);
Expect.equals(1152921504606846975, j >> 3);
int j = 0x7FFFFFFFFFFFF000;
Expect.equals(4611686018427385856, j >> 1);
Expect.equals(2305843009213692928, j >> 2);
Expect.equals(1152921504606846464, j >> 3);
Expect.equals(3, j >> 61);
Expect.equals(1, j >> 62);
Expect.equals(0, j >> 63);
Expand Down
12 changes: 6 additions & 6 deletions Language/Expressions/Shift/integer_t03.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ main() {
int i = 1;
Expect.equals(0, i >>> 1);
Expect.equals(0, i >>> 2);
Expect.equals(1, i >>> 64);
Expect.equals(0, i >>> 64);
Expect.equals(0, i >>> 100);

int j = 0x7FFFFFFFFFFFFFFF;
Expect.equals(0, j >>> 1);
Expect.equals(0, j >>> 2);
Expect.equals(0, j >>> 3);
int j = 0x7FFFFFFFFFFFF000;
Expect.equals(4611686018427385856, j >>> 1);
Expect.equals(2305843009213692928, j >>> 2);
Expect.equals(1152921504606846464, j >>> 3);

int k = 129;
Expect.equals(4, k >>> 261);
Expect.equals(0, k >>> 261);

int l = 1295555555;
Expect.equals(l, l >>> 0);
Expand Down
28 changes: 28 additions & 0 deletions Language/Expressions/Shift/integer_t06.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* 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.
*/
/**
* @assertion N/A
* @description Checks that left shift works with big size integers as expected.
* This test must be skipped on JavaScript
* @author sgrekhov@unipro.ru
*/
import '../../../Utils/expect.dart';

main() {
int i = 1;
Expect.equals(-9223372036854775808, i << 63);

int j = 0x7FFFFFFFFFFFFFFF;
Expect.equals(-2, j << 1);
Expect.equals(-4, j << 2);
Expect.equals(-8, j << 3);
Expect.equals(-16, j << 4);
Expect.equals(-32, j << 5);
Expect.equals(-64, j << 6);
Expect.equals(0, j << 64);
Expect.equals(0, j << 65);
Expect.equals(0, j << 100);
}
31 changes: 31 additions & 0 deletions Language/Expressions/Shift/integer_t07.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.
*/
/**
* @assertion N/A
* @description Checks that right shift works with big size integers as expected
* This test must be skipped on JavaScript
* @author sgrekhov@unipro.ru
*/
import '../../../Utils/expect.dart';

main() {
int i = 1;
Expect.equals(0, i >> 1);
Expect.equals(0, i >> 2);
Expect.equals(0, i >> 64);
Expect.equals(0, i >> 100);

int j = 0x7FFFFFFFFFFFFFFF;
Expect.equals(4611686018427387903, j >> 1);
Expect.equals(2305843009213693951, j >> 2);
Expect.equals(1152921504606846975, j >> 3);
Expect.equals(3, j >> 61);
Expect.equals(1, j >> 62);
Expect.equals(0, j >> 63);
Expect.equals(0, j >> 64);
Expect.equals(0, j >> 65);
Expect.equals(0, j >> 100);
}

0 comments on commit 2a09bd3

Please sign in to comment.