Skip to content

Commit 1fb2046

Browse files
committed
[GR-65433] Correction of BitSets.equals().
PullRequest: graal/20952
2 parents eeb3060 + 4394adf commit 1fb2046

File tree

2 files changed

+21
-4
lines changed
  • regex/src
    • com.oracle.truffle.regex.test/src/com/oracle/truffle/regex/tregex
    • com.oracle.truffle.regex/src/com/oracle/truffle/regex/util

2 files changed

+21
-4
lines changed

regex/src/com.oracle.truffle.regex.test/src/com/oracle/truffle/regex/tregex/TBitSetTest.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -250,6 +250,23 @@ public void testSubtract() {
250250
reset();
251251
}
252252

253+
@Test
254+
public void testEquals() {
255+
TBitSet small = new TBitSet(128);
256+
TBitSet large = new TBitSet(256);
257+
Assert.assertTrue(small.equals(large));
258+
Assert.assertTrue(large.equals(small));
259+
small.set(42);
260+
Assert.assertFalse(small.equals(large));
261+
Assert.assertFalse(large.equals(small));
262+
large.set(42);
263+
Assert.assertTrue(small.equals(large));
264+
Assert.assertTrue(large.equals(small));
265+
large.set(211);
266+
Assert.assertFalse(small.equals(large));
267+
Assert.assertFalse(large.equals(small));
268+
}
269+
253270
private void checkSet(int i) {
254271
oracle.set(i);
255272
bitSet.set(i);

regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/util/BitSets.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -260,12 +260,12 @@ public static boolean equals(long[] bs1, long[] bs2) {
260260
}
261261
}
262262
for (int i = bs1.length; i < bs2.length; i++) {
263-
if (bs1[i] != 0) {
263+
if (bs2[i] != 0) {
264264
return false;
265265
}
266266
}
267267
for (int i = bs2.length; i < bs1.length; i++) {
268-
if (bs2[i] != 0) {
268+
if (bs1[i] != 0) {
269269
return false;
270270
}
271271
}

0 commit comments

Comments
 (0)