Skip to content

Commit

Permalink
JS-equals handles java.util.Set as well (closes #144, again)
Browse files Browse the repository at this point in the history
  • Loading branch information
michbarsinai committed Jan 28, 2021
1 parent e9db766 commit 99aae35
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ public static boolean jsEquals(Object o1, Object o2) {
return jsListEquals((List)o1, (List)o2);
}

if ( o1 instanceof Set && o2 instanceof Set ) {
return jsSetEquals((Set)o1, (Set)o2);
}

// Concatenated strings in Rhino are not java.lang.Strings. We need to manually
// resolve to String semantics, which is what the following lines do.
if (o1 instanceof ConsString) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,14 @@ public void testJsEquals_Set() {
jsExp("[42, 'dark castle', 'kings quest']")
);

assertTrue( ScriptableUtils.jsSetEquals(mpA, mpAb));
assertTrue( ScriptableUtils.jsSetEquals(mpA, mpA));
assertTrue( ScriptableUtils.jsSetEquals(null, null));
assertTrue( ScriptableUtils.jsEquals(mpA, mpAb));
assertTrue( ScriptableUtils.jsEquals(mpA, mpA));
assertTrue( ScriptableUtils.jsEquals(null, null));

assertFalse( ScriptableUtils.jsSetEquals(mpA, null));
assertFalse( ScriptableUtils.jsSetEquals(mpA, mpAdim));
assertFalse( ScriptableUtils.jsSetEquals(mpA, mpB));
assertFalse( ScriptableUtils.jsSetEquals(mpA, mpC));
assertFalse( ScriptableUtils.jsEquals(mpA, null));
assertFalse( ScriptableUtils.jsEquals(mpA, mpAdim));
assertFalse( ScriptableUtils.jsEquals(mpA, mpB));
assertFalse( ScriptableUtils.jsEquals(mpA, mpC));
}


Expand Down

0 comments on commit 99aae35

Please sign in to comment.