Skip to content

Commit f65dbf6

Browse files
committed
added unit tests for newShort and newLong, updated readme for newLong
1 parent 9308985 commit f65dbf6

6 files changed

Lines changed: 37 additions & 0 deletions

File tree

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ try {
127127
* [newArray](#javaNewArray)
128128
* [newByte](#javaNewByte)
129129
* [newShort](#javaNewShort)
130+
* [newLong](#javaNewLong)
130131
* [newChar](#javaNewChar)
131132
* [newProxy](#javaNewProxy)
132133
@@ -294,6 +295,19 @@ __Example__
294295
295296
var s = java.newShort(12);
296297
298+
<a name="javaNewLong" />
299+
**java.newLong(val)**
300+
301+
Creates a new java long. This is needed because javascript does not have the concept of a long.
302+
303+
__Arguments__
304+
305+
* val - The value of the java long.
306+
307+
__Example__
308+
309+
var s = java.newLong(12);
310+
297311
<a name="javaNewChar" />
298312
**java.newChar(val)**
299313

test/Test$SubClass.class

0 Bytes
Binary file not shown.

test/Test$SuperClass.class

0 Bytes
Binary file not shown.

test/Test.class

122 Bytes
Binary file not shown.

test/Test.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public Test() {}
2929
public static long staticMethodReturnLong() { return java.lang.Long.MAX_VALUE; }
3030

3131
public static int staticByte(byte b) { return (int)b; }
32+
public static int staticShort(short s) { return (int)s; }
33+
public static int staticLong(long l) { return (int)l; }
34+
3235
public static int staticChar(char ch) { return (int)ch; }
3336
public static short[] staticShortArray(Short[] arg) {
3437
short[] b = new short[arg.length];

test/simple-test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,26 @@ exports['Simple'] = nodeunit.testCase({
186186
test.done();
187187
},
188188

189+
"method taking a short": function(test) {
190+
var s = java.newShort(1);
191+
test.equal('java.lang.Short', s.getClassSync().getNameSync());
192+
test.equal('1', s.toStringSync());
193+
var r = java.callStaticMethodSync("Test", "staticShort", s);
194+
console.log(r);
195+
test.equal(r, 1);
196+
test.done();
197+
},
198+
199+
"method taking a long": function(test) {
200+
var l = java.newLong(1);
201+
test.equal('java.lang.Long', l.getClassSync().getNameSync());
202+
test.equal('1', l.toStringSync());
203+
var r = java.callStaticMethodSync("Test", "staticLong", l);
204+
console.log(r);
205+
test.equal(r, 1);
206+
test.done();
207+
},
208+
189209
"method taking a char (number)": function(test) {
190210
var ch = java.newChar(97); // 'a'
191211
test.equal('java.lang.Character', ch.getClassSync().getNameSync());

0 commit comments

Comments
 (0)