Skip to content

Commit 5c5c516

Browse files
committed
Issue #997: existing triple-shift tests corrected.
1 parent 3500b36 commit 5c5c516

File tree

3 files changed

+39
-10
lines changed

3 files changed

+39
-10
lines changed

Language/Expressions/Shift/integer_t04.dart

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,18 @@
1111
*/
1212
// SharedOptions=--enable-experiment=triple-shift
1313

14+
import "../../../Utils/expect.dart";
15+
1416
main() {
1517
int i1 = 12345;
1618
int i2 = -11;
1719
int i3 = -12345;
1820

19-
var res1 = i1 >>> i2; //# 01: compile-time error
20-
var res2 = i1 >>> i3; //# 02: compile-time error
21-
var res3 = i2 >>> i3; //# 03: compile-time error
22-
var res4 = i3 >>> i2; //# 04: compile-time error
23-
24-
var res5 = i1 >>> -2; //# 05: compile-time error
25-
var res6 = 2000 >>> i3; //# 06: compile-time error
26-
var res7 = 2000 >>> -14; //# 07: compile-time error
21+
Expect.throws(() { i1 >>> i2; });
22+
Expect.throws(() { i1 >>> i3; });
23+
Expect.throws(() { i2 >>> i3; });
24+
Expect.throws(() { i3 >>> i2; });
25+
Expect.throws(() { i1 >>> -2; });
26+
Expect.throws(() { 2000 >>> i3; });
27+
Expect.throws(() { 150 >>> -14; });
2728
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
3+
* for details. All rights reserved. Use of this source code is governed by a
4+
* BSD-style license that can be found in the LICENSE file.
5+
*/
6+
/**
7+
* @assertion N/A
8+
* @description Checks that triple right shift argument cannot be negative and
9+
* cause compile time error if this is a constant expression (see co19 Issue
10+
* #355 for more details)
11+
12+
*/
13+
// SharedOptions=--enable-experiment=triple-shift
14+
15+
main() {
16+
const int i1 = 12345;
17+
const int i2 = -11;
18+
const int i3 = -12345;
19+
20+
const res1 = i1 >>> i2; //# 01: compile-time error
21+
const res2 = i1 >>> i3; //# 02: compile-time error
22+
const res3 = i2 >>> i3; //# 03: compile-time error
23+
const res4 = i3 >>> i2; //# 04: compile-time error
24+
25+
const res5 = i1 >>> -2; //# 05: compile-time error
26+
const res6 = 2000 >>> i3; //# 06: compile-time error
27+
const res7 = 2000 >>> -14; //# 07: compile-time error
28+
}

LanguageFeatures/nnbd/triple-shift/local_variable_read_A02_t03.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ main() {
2323
if (b) {
2424
x = 42;
2525
}
26-
x >>>= 2;
26+
x >>>= 2;
2727
Expect.equals(42 >>> 2, x);
2828

2929
var y;
3030
b = false;
3131
if (b) {
3232
y = 42;
3333
}
34-
Expect.throws(() {x >>>= 2;});
34+
Expect.throws(() {y >>>= 2;});
3535
}

0 commit comments

Comments
 (0)