From 65078ea943553f6f0893a73f651cec6c4d661ca4 Mon Sep 17 00:00:00 2001 From: Adrien Leravat Date: Tue, 7 Feb 2023 10:10:45 -0800 Subject: [PATCH] Explorer: make use of `!=` in Carbon lit (#2586) Swap `not (a == b)` for `a != b` in test now that we have it. --- .../testdata/alias/member_name_alias.carbon | 27 +++++++++---------- .../recursive.carbon | 2 +- explorer/testdata/operators/bitwise.carbon | 24 ++++++++--------- explorer/testdata/operators/mod_edges.carbon | 14 +++++----- explorer/testdata/operators/shift.carbon | 20 +++++++------- explorer/testdata/while/basic.carbon | 2 +- explorer/testdata/while/continue.carbon | 2 +- .../testdata/while/convert_condition.carbon | 2 +- 8 files changed, 46 insertions(+), 47 deletions(-) diff --git a/explorer/testdata/alias/member_name_alias.carbon b/explorer/testdata/alias/member_name_alias.carbon index f6f59cf315b3..a50fab5bf300 100644 --- a/explorer/testdata/alias/member_name_alias.carbon +++ b/explorer/testdata/alias/member_name_alias.carbon @@ -36,44 +36,43 @@ alias i32IM = i32.(IM); fn Main() -> i32 { var a: A = {.n = 0}; - // TODO: Use != once we support it. - if (not (A.(IF)() == 1)) { + if (A.(IF)() != 1) { return 1; } - if (not (a.(IF)() == 1)) { + if (a.(IF)() != 1) { return 2; } - if (not (a.(IM)() == 2)) { + if (a.(IM)() != 2) { return 3; } - if (not (a.(A.(IM))() == 2)) { + if (a.(A.(IM))() != 2) { return 4; } - if (not (AIF() == 1)) { + if (AIF() != 1) { return 5; } - if (not (a.(AIM)() == 2)) { + if (a.(AIM)() != 2) { return 6; } - if (not (a.(AG)() == 3)) { + if (a.(AG)() != 3) { return 7; } - if (not (i32.(IF)() == 4)) { + if (i32.(IF)() != 4) { return 8; } - if (not (0.(IF)() == 4)) { + if (0.(IF)() != 4) { return 9; } - if (not (0.(IM)() == 5)) { + if (0.(IM)() != 5) { return 10; } - if (not (0.(i32.(IM))() == 5)) { + if (0.(i32.(IM))() != 5) { return 11; } - if (not (i32IF() == 4)) { + if (i32IF() != 4) { return 12; } - if (not (0.(i32IM)() == 5)) { + if (0.(i32IM)() != 5) { return 13; } return 0; diff --git a/explorer/testdata/experimental_continuation/recursive.carbon b/explorer/testdata/experimental_continuation/recursive.carbon index e0bfe8ca266e..b5b625e0847f 100644 --- a/explorer/testdata/experimental_continuation/recursive.carbon +++ b/explorer/testdata/experimental_continuation/recursive.carbon @@ -31,7 +31,7 @@ fn Main() -> i32 { } var sum: i32 = 0; var count: i32 = 5; - while (not (count == 0)) { + while (count != 0) { __run k; sum = sum + current; count = count - 1; diff --git a/explorer/testdata/operators/bitwise.carbon b/explorer/testdata/operators/bitwise.carbon index 66919c708046..678afed6bb5b 100644 --- a/explorer/testdata/operators/bitwise.carbon +++ b/explorer/testdata/operators/bitwise.carbon @@ -10,21 +10,21 @@ package ExplorerTest api; fn Main() -> i32 { - if (not (^0 == -1)) { return 11; } - if (not (^1 == -2)) { return 12; } - if (not (^(-3) == 2)) { return 13; } + if (^0 != -1) { return 11; } + if (^1 != -2) { return 12; } + if (^(-3) != 2) { return 13; } - if (not (3 & 6 == 2)) { return 21; } - if (not (-1 & 4 == 4)) { return 22; } - if (not (-1 & -2 == -2)) { return 23; } + if (3 & 6 != 2) { return 21; } + if (-1 & 4 != 4) { return 22; } + if (-1 & -2 != -2) { return 23; } - if (not (1 | 4 == 5)) { return 31; } - if (not (5 | 3 == 7)) { return 32; } - if (not (-2 | 1 == -1)) { return 33; } + if (1 | 4 != 5) { return 31; } + if (5 | 3 != 7) { return 32; } + if (-2 | 1 != -1) { return 33; } - if (not (1 ^ 4 == 5)) { return 41; } - if (not (5 ^ 3 == 6)) { return 42; } - if (not (-2 ^ -3 == 3)) { return 43; } + if (1 ^ 4 != 5) { return 41; } + if (5 ^ 3 != 6) { return 42; } + if (-2 ^ -3 != 3) { return 43; } return 0; } diff --git a/explorer/testdata/operators/mod_edges.carbon b/explorer/testdata/operators/mod_edges.carbon index 6683eb7e95af..88237395d04c 100644 --- a/explorer/testdata/operators/mod_edges.carbon +++ b/explorer/testdata/operators/mod_edges.carbon @@ -17,36 +17,36 @@ fn Main() -> i32 { var x : i32 = 7 % 2; - if( not (x == 1) ){ + if( x != 1){ return 1; } x = (3*3) % 3; - if( not (x == 0)){ + if( x != 0){ return 2; } x = (4+4+4+4) % (2+1); - if( not (x == 1) ){ + if( x != 1){ return 3; } x = 15 % (identFn(2)+1); - if( not (x == 0)){ + if( x != 0){ return 4; } x = -15 % 7; - if( not (x == -1)){ + if( x != -1){ return 5; } x = 15 % -7; - if( not ( x == 1)){ + if( x != 1){ return 6; } x = -15 % -identFn(7); - if( not (x == -1)){ + if( x != -1){ return 7; } diff --git a/explorer/testdata/operators/shift.carbon b/explorer/testdata/operators/shift.carbon index be1ad0826738..2e62fdaf2128 100644 --- a/explorer/testdata/operators/shift.carbon +++ b/explorer/testdata/operators/shift.carbon @@ -12,16 +12,16 @@ package ExplorerTest api; fn Main() -> i32 { - if (not (1 << 0 == 1)) { return 1; } - if (not (1 << 3 == 8)) { return 2; } - if (not (0 << 3 == 0)) { return 3; } - if (not (3 << 1 == 6)) { return 4; } - if (not (-1 << 2 == -4)) { return 5; } - if (not (1 >> 0 == 1)) { return 6; } - if (not (1 >> 1 == 0)) { return 7; } - if (not (3 >> 1 == 1)) { return 8; } - if (not (-1 >> 1 == -1)) { return 9; } - if (not (-2 >> 1 == -1)) { return 10; } + if (1 << 0 != 1) { return 1; } + if (1 << 3 != 8) { return 2; } + if (0 << 3 != 0) { return 3; } + if (3 << 1 != 6) { return 4; } + if (-1 << 2 != -4) { return 5; } + if (1 >> 0 != 1) { return 6; } + if (1 >> 1 != 0) { return 7; } + if (3 >> 1 != 1) { return 8; } + if (-1 >> 1 != -1) { return 9; } + if (-2 >> 1 != -1) { return 10; } var n: i32 = 1; n <<= 3; diff --git a/explorer/testdata/while/basic.carbon b/explorer/testdata/while/basic.carbon index 8ab902f07f3a..56f267e2967b 100644 --- a/explorer/testdata/while/basic.carbon +++ b/explorer/testdata/while/basic.carbon @@ -11,7 +11,7 @@ package ExplorerTest api; fn Main() -> i32 { var x: auto = 2; - while (not (x == 0)) { + while (x != 0) { x = x - 1; } return x; diff --git a/explorer/testdata/while/continue.carbon b/explorer/testdata/while/continue.carbon index 87a206a72c60..536459acc8cd 100644 --- a/explorer/testdata/while/continue.carbon +++ b/explorer/testdata/while/continue.carbon @@ -11,7 +11,7 @@ package ExplorerTest api; fn Main() -> i32 { var x: auto = 2; - while (not (x == 0)) { + while (x != 0) { x = x - 1; continue; x = x + 1; diff --git a/explorer/testdata/while/convert_condition.carbon b/explorer/testdata/while/convert_condition.carbon index 4adea6fb7181..83ce3d38f0bf 100644 --- a/explorer/testdata/while/convert_condition.carbon +++ b/explorer/testdata/while/convert_condition.carbon @@ -14,7 +14,7 @@ class LazyNe { var v2: i32; impl as ImplicitAs(bool) { fn Convert[self: Self]() -> bool { - return not (self.v1 == self.v2); + return self.v1 != self.v2; } } fn Make(v1: i32, v2: i32) -> Self {