@@ -53,14 +53,27 @@ describe('metacall', () => {
5353 const asd = require ( 'asd.mock' ) ;
5454 assert . notStrictEqual ( asd , undefined ) ;
5555 assert . strictEqual ( asd . my_empty_func ( ) , 1234 ) ;
56- assert . strictEqual ( asd . my_empty_func_str ( ) , 'Hello World\u0000 ' ) ;
56+ assert . strictEqual ( asd . my_empty_func_str ( ) , 'Hello World' ) ;
5757 assert . strictEqual ( asd . my_empty_func_int ( ) , 1234 ) ;
58- assert . strictEqual ( asd . new_args ( 'a' ) , 'Hello World\u0000 ' ) ;
59- assert . strictEqual ( asd . two_str ( '1' , '2' ) , 'Hello World\u0000 ' ) ;
58+ assert . strictEqual ( asd . new_args ( 'a' ) , 'Hello World' ) ;
59+ assert . strictEqual ( asd . two_str ( '1' , '2' ) , 'Hello World' ) ;
6060 assert . strictEqual ( asd . two_doubles ( 4.4 , 5.5 ) , 3.1416 ) ;
61- assert . strictEqual ( asd . three_str ( 'a' , 'b' , 'c' ) , 'Hello World\u0000 ' ) ;
61+ assert . strictEqual ( asd . three_str ( 'a' , 'b' , 'c' ) , 'Hello World' ) ;
6262 assert . strictEqual ( asd . mixed_args ( 'a' , 3 , 4 , 3.4 , 'NOT IMPLEMENTED' ) , 65 ) ;
6363 } ) ;
64+ it ( 'metacall_load_from_file (cob)' , ( ) => {
65+ assert . strictEqual ( metacall_load_from_file ( 'cob' , [ 'say.cob' ] ) , undefined ) ;
66+
67+ const script = metacall_handle ( 'cob' , 'say' ) ;
68+
69+ // Cobol tests are optional (in order to pass CI/CD)
70+ if ( script ) {
71+ assert . notStrictEqual ( script , undefined ) ;
72+ assert . strictEqual ( script . name , 'say' ) ;
73+
74+ assert . strictEqual ( metacall ( 'say' , 'Hello, ' , 'world!' ) , 0 ) ;
75+ }
76+ } ) ;
6477 it ( 'require (py)' , ( ) => {
6578 const example = require ( 'example.py' ) ;
6679 assert . notStrictEqual ( example , undefined ) ;
@@ -89,7 +102,7 @@ describe('metacall', () => {
89102 describe ( 'call' , ( ) => {
90103 it ( 'metacall (mock)' , ( ) => {
91104 assert . strictEqual ( metacall ( 'my_empty_func' ) , 1234 ) ;
92- assert . strictEqual ( metacall ( 'three_str' , 'a' , 'b' , 'c' ) , 'Hello World\u0000 ' ) ;
105+ assert . strictEqual ( metacall ( 'three_str' , 'a' , 'b' , 'c' ) , 'Hello World' ) ;
93106 } ) ;
94107 it ( 'metacall (py)' , ( ) => {
95108 assert . strictEqual ( metacall ( 'multiply' , 2 , 2 ) , 4 ) ;
@@ -135,9 +148,11 @@ describe('metacall', () => {
135148
136149 // Opaque pointer for class instances
137150 assert . strictEqual ( f . function_capsule_method ( f . function_capsule_new_class ( ) ) , 'hello world' ) ;
151+ assert . strictEqual ( f . function_capsule_method ( f . function_capsule_new_class ( ) ) , 'hello world' ) ; // Check for function lifetime
138152
139153 // Opaque pointer for class instances with callback
140154 assert . strictEqual ( f . function_capsule_cb ( ( klass ) => f . function_capsule_method ( klass ) ) , 'hello world' ) ;
155+ assert . strictEqual ( f . function_capsule_cb ( ( klass ) => f . function_capsule_method ( klass ) ) , 'hello world' ) ; // Check for function lifetime
141156
142157 // Double recursion
143158 const sum = ( value , f ) => value <= 0 ? 0 : value + f ( value - 1 , sum ) ;
@@ -147,18 +162,31 @@ describe('metacall', () => {
147162 assert . strictEqual ( f . function_sum ( 5 , sum ) , 15 ) ; // Check for function lifetime
148163
149164 // Factorial composition (@trgwii)
165+ // console.log("------------------------------------------------");
150166 // const fact = f.function_factorial(c => v => v <= 0 ? 1 : v);
167+ // console.log("------------------------------------------------");
151168 // assert.strictEqual(fact(1), 1);
169+ // console.log("------------------------------------------------");
152170 // assert.strictEqual(fact(2), 2);
171+ // console.log("------------------------------------------------");
153172 // assert.strictEqual(fact(3), 6);
173+ // console.log("------------------------------------------------");
154174 // assert.strictEqual(fact(50000), 2499950000);
155175
176+ // console.log("------------------------------------------------");
156177 // const js_factorial = f.function_chain((x) => (n) => n == 0 ? 1 : n * x(x)(n - 1));
157178 // assert.notStrictEqual(js_factorial, undefined);
179+ // console.log("------------------------------------------------");
180+ // assert.strictEqual(js_factorial(5), 120);
181+ // console.log("------------------------------------------------");
158182 // assert.strictEqual(js_factorial(5), 120);
159183
184+ // console.log("------------------------------------------------");
160185 // const py_factorial = f.function_chain(f.function_factorial);
161186 // assert.notStrictEqual(py_factorial, undefined);
187+ // console.log("------------------------------------------------");
188+ // assert.strictEqual(py_factorial(5), 120);
189+ // console.log("------------------------------------------------");
162190 // assert.strictEqual(py_factorial(5), 120);
163191 } ) ;
164192 } ) ;
0 commit comments