[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #48875] java integration: function isequal
From: |
Ernst Reissner |
Subject: |
[Octave-bug-tracker] [bug #48875] java integration: function isequal |
Date: |
Tue, 23 Aug 2016 19:25:45 +0000 (UTC) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:48.0) Gecko/20100101 Firefox/48.0 |
Follow-up Comment #1, bug #48875 (project octave):
This patch takes only java into account.
I consider it ok if the first element is java or []
representing null in java.
I did not check the other cases
and thus this patch does not include documentation.
Add it if my fix is ok.
Please keep me informed.
My private tests (i am interested mostly in java)
are based on OctaveInterfaceTester i also provide.
my equality tests are also implemented in java.
I give you just the source:
// the tests performed here, compare just java objects including null
void testIsequal() {
this.oct.eval("tester = javaObject(" + TESTER_NAME + ");");
// tests including null
this.oct.eval("b=isequal([], tester);");
assertTrue(!this.oct.getBool("b"));
this.oct.eval("b=isequal(tester, []);");
assertTrue(!this.oct.getBool("b"));
// test with different classes
this.oct.eval("bd=javaObject('java.math.BigDecimal',4.2);");
this.oct.eval("b=isequal(tester, bd);");
assertTrue(!this.oct.getBool("b"));
// tests with same classes but not equal
this.oct.eval("bd1=javaObject('java.math.BigDecimal',4.2);");
this.oct.eval("bd2=javaObject('java.math.BigDecimal',4.3);");
this.oct.eval("b=isequal(bd1, bd2);");
assertTrue(!this.oct.getBool("b"));
// tests with same classes and equal
this.oct.eval("bd1=javaObject('java.math.BigDecimal',4.2);");
this.oct.eval("bd2=javaObject('java.math.BigDecimal',4.2);");
this.oct.eval("b=isequal(bd1, bd2);");
assertTrue(this.oct.getBool("b"));
// tests including the tester: test of specific equals method
this.oct.eval("t1 = javaObject(" + TESTER_NAME + ");");
this.oct.eval("t2 = javaObject(" + TESTER_NAME + ");");
this.oct.eval("b=isequal(t1, t2);");
assertTrue(this.oct.getBool("b"));
this.oct.eval("t1 = javaObject(" + TESTER_NAME + ");");
this.oct.eval("t2 = javaObject(" + TESTER_NAME + ");");
this.oct.eval("t1.bdVal = javaObject('java.math.BigDecimal',4.2);");
this.oct.eval("b=isequal(t1, t2);");
assertTrue(!this.oct.getBool("b"));
this.oct.eval("t1 = javaObject(" + TESTER_NAME + ");");
this.oct.eval("t2 = javaObject(" + TESTER_NAME + ");");
this.oct.eval("t1.bVal = 42;");
this.oct.eval("t1.bdVal = javaObject('java.math.BigDecimal',4.2);");
this.oct.eval("t2.bVal = 42;");
this.oct.eval("t2.bdVal = javaObject('java.math.BigDecimal',4.2);");
this.oct.eval("b=isequal(t1, t2);");
assertTrue(this.oct.getBool("b"));
}
(file #38333, file #38334)
_______________________________________________________
Additional Item Attachment:
File name: patchBug448875.patch Size:2 KB
File name: OctaveInterfaceTester.java Size:6 KB
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?48875>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/