@@ -17,7 +17,7 @@ exports['Simple'] = nodeunit.testCase({
1717 console . log ( 'classpath' , java . classpath ) ;
1818 java . classpath = [ "test/" ] ;
1919 test . fail ( "Exception should be thrown" ) ;
20- } catch ( e ) {
20+ } catch ( e ) {
2121 // ok
2222 }
2323 test . done ( ) ;
@@ -29,7 +29,7 @@ exports['Simple'] = nodeunit.testCase({
2929 console . log ( 'options' , java . options ) ;
3030 java . options = [ "newoption" ] ;
3131 test . fail ( "Exception should be thrown" ) ;
32- } catch ( e ) {
32+ } catch ( e ) {
3333 // ok
3434 }
3535 test . done ( ) ;
@@ -41,7 +41,7 @@ exports['Simple'] = nodeunit.testCase({
4141 console . log ( 'nativeBindingLocation' , java . nativeBindingLocation ) ;
4242 java . nativeBindingLocation = "newNativeBindingLocation" ;
4343 test . fail ( "Exception should be thrown" ) ;
44- } catch ( e ) {
44+ } catch ( e ) {
4545 // ok
4646 }
4747 test . done ( ) ;
@@ -72,20 +72,32 @@ exports['Simple'] = nodeunit.testCase({
7272
7373 "test method does not exists (async)" : function ( test ) {
7474 java . callStaticMethod ( "java.lang.System" , "badMethod" , function ( err , result ) {
75- if ( err ) { test . done ( ) ; return ; }
75+ if ( err ) {
76+ test . done ( ) ;
77+ return ;
78+ }
7679 test . done ( new Error ( "should throw exception" ) ) ;
7780 } ) ;
7881 } ,
7982
8083 "create an instance of a class and call methods (getName) (async)" : function ( test ) {
8184 java . newInstance ( "java.util.ArrayList" , function ( err , list ) {
82- if ( err ) { console . log ( err ) ; return ; }
85+ if ( err ) {
86+ console . log ( err ) ;
87+ return ;
88+ }
8389 test . ok ( list ) ;
84- if ( list ) {
90+ if ( list ) {
8591 list . getClass ( function ( err , result ) {
86- if ( err ) { console . log ( err ) ; return ; }
92+ if ( err ) {
93+ console . log ( err ) ;
94+ return ;
95+ }
8796 result . getName ( function ( err , result ) {
88- if ( err ) { console . log ( err ) ; return ; }
97+ if ( err ) {
98+ console . log ( err ) ;
99+ return ;
100+ }
89101 test . equal ( result , "java.util.ArrayList" ) ;
90102 test . done ( ) ;
91103 } ) ;
@@ -110,11 +122,17 @@ exports['Simple'] = nodeunit.testCase({
110122
111123 "create an instance of a class and call methods (size) (async)" : function ( test ) {
112124 java . newInstance ( "java.util.ArrayList" , function ( err , list ) {
113- if ( err ) { console . log ( err ) ; return ; }
125+ if ( err ) {
126+ console . log ( err ) ;
127+ return ;
128+ }
114129 test . ok ( list ) ;
115- if ( list ) {
130+ if ( list ) {
116131 list . size ( function ( err , result ) {
117- if ( err ) { console . log ( err ) ; return ; }
132+ if ( err ) {
133+ console . log ( err ) ;
134+ return ;
135+ }
118136 test . equal ( result , 0 ) ;
119137 test . done ( ) ;
120138 } ) ;
@@ -196,6 +214,26 @@ exports['Simple'] = nodeunit.testCase({
196214 test . done ( ) ;
197215 } ,
198216
217+ "method taking a double" : function ( test ) {
218+ var s = java . newDouble ( 3.14 ) ;
219+ test . equal ( 'java.lang.Double' , s . getClassSync ( ) . getNameSync ( ) ) ;
220+ test . equal ( '3.14' , s . toStringSync ( ) ) ;
221+ var r = java . callStaticMethodSync ( "Test" , "staticDouble" , s ) ;
222+ console . log ( r ) ;
223+ test . ok ( Math . abs ( r - 3.14 ) < 0.0001 , r + " != 3.14" ) ;
224+ test . done ( ) ;
225+ } ,
226+
227+ "method taking a float" : function ( test ) {
228+ var s = java . newFloat ( 3.14 ) ;
229+ test . equal ( 'java.lang.Float' , s . getClassSync ( ) . getNameSync ( ) ) ;
230+ test . equal ( '3.14' , s . toStringSync ( ) ) ;
231+ var r = java . callStaticMethodSync ( "Test" , "staticFloat" , s ) ;
232+ console . log ( r ) ;
233+ test . ok ( Math . abs ( r - 3.14 ) < 0.0001 , r + " != 3.14" ) ;
234+ test . done ( ) ;
235+ } ,
236+
199237 "method taking a long" : function ( test ) {
200238 var l = java . newLong ( 1 ) ;
201239 test . equal ( 'java.lang.Long' , l . getClassSync ( ) . getNameSync ( ) ) ;
0 commit comments