@@ -46,11 +46,11 @@ describe('metacall', () => {
4646 } ) ;
4747 } ) ;
4848
49- // TODO: This fails in NodeJS 15.x because the error message is slightly different
50- /*
5149 describe ( 'fail' , ( ) => {
50+ // TODO: This fails in NodeJS 15.x because the error message is slightly different
5251 it ( 'require' , ( ) => {
53- assert.throws(() => { require('./asd.invalid') }, new Error('Cannot find module \'./asd.invalid\''));
52+ // TODO: This generates a segfault in C# Loader
53+ // assert.throws(() => { require('./asd.invalid') }, new Error('Cannot find module \'./asd.invalid\''));
5454 // TODO: Improve error messages
5555 assert . throws ( ( ) => { require ( './asd.py' ) } , new Error ( 'MetaCall could not load from file' ) ) ;
5656 assert . throws ( ( ) => { require ( './asd.rb' ) } , new Error ( 'MetaCall could not load from file' ) ) ;
@@ -59,7 +59,6 @@ describe('metacall', () => {
5959 assert . throws ( ( ) => { require ( './asd.tsx' ) } , new Error ( 'MetaCall could not load from file' ) ) ;
6060 } ) ;
6161 } ) ;
62- */
6362
6463 describe ( 'load' , ( ) => {
6564 it ( 'metacall_load_from_file (py)' , ( ) => {
@@ -109,8 +108,6 @@ describe('metacall', () => {
109108 } ) ;
110109 }
111110 it ( 'require (mock)' , ( ) => {
112- // TODO: Both methods work, should we disable the commented out style to be NodeJS compilant?
113- // const asd = require('asd.mock');
114111 const asd = require ( './asd.mock' ) ;
115112 assert . notStrictEqual ( asd , undefined ) ;
116113 assert . strictEqual ( asd . my_empty_func ( ) , 1234 ) ;
@@ -123,20 +120,14 @@ describe('metacall', () => {
123120 assert . strictEqual ( asd . mixed_args ( 'a' , 3 , 4 , 3.4 , 'NOT IMPLEMENTED' ) , 65 ) ;
124121 } ) ;
125122 it ( 'require (py)' , ( ) => {
126- const verify = ( example ) => {
127- assert . notStrictEqual ( example , undefined ) ;
128- assert . strictEqual ( example . multiply ( 2 , 2 ) , 4 ) ;
129- assert . strictEqual ( example . divide ( 4.0 , 2.0 ) , 2.0 ) ;
130- assert . strictEqual ( example . sum ( 2 , 2 ) , 4 ) ;
131- assert . strictEqual ( example . strcat ( '2' , '2' ) , '22' ) ;
132- assert . deepStrictEqual ( example . return_array ( ) , [ 1 , 2 , 3 ] ) ;
133- assert . deepStrictEqual ( example . return_same_array ( [ 1 , 2 , 3 ] ) , [ 1 , 2 , 3 ] ) ;
134- } ;
135-
136- verify ( require ( './example.py' ) ) ;
137-
138- // TODO: Should we enable this format? I think it should work right now but it does not, we must review it
139- // verify(require('example.py'));
123+ const example = require ( './example.py' ) ;
124+ assert . notStrictEqual ( example , undefined ) ;
125+ assert . strictEqual ( example . multiply ( 2 , 2 ) , 4 ) ;
126+ assert . strictEqual ( example . divide ( 4.0 , 2.0 ) , 2.0 ) ;
127+ assert . strictEqual ( example . sum ( 2 , 2 ) , 4 ) ;
128+ assert . strictEqual ( example . strcat ( '2' , '2' ) , '22' ) ;
129+ assert . deepStrictEqual ( example . return_array ( ) , [ 1 , 2 , 3 ] ) ;
130+ assert . deepStrictEqual ( example . return_same_array ( [ 1 , 2 , 3 ] ) , [ 1 , 2 , 3 ] ) ;
140131 } ) ;
141132 it ( 'require (py class)' , ( ) => {
142133 const classname = require ( './classname.py' ) ;
@@ -167,8 +158,6 @@ describe('metacall', () => {
167158 assert . strictEqual ( py_encode_basestring_ascii ( 'asd' ) , '"asd"' ) ;
168159 } ) ;
169160 it ( 'require (rb)' , ( ) => {
170- // TODO: Both methods work, should we disable the commented out style to be NodeJS compilant?
171- // const cache = require('cache.rb');
172161 const cache = require ( './cache.rb' ) ;
173162 assert . notStrictEqual ( cache , undefined ) ;
174163 assert . strictEqual ( cache . cache_set ( 'asd' , 'efg' ) , undefined ) ;
@@ -193,8 +182,6 @@ describe('metacall', () => {
193182 } ) ;
194183 } ) ;
195184
196- // TODO: This fails because classes are not implemented in the NodeJS loader
197- /*
198185 describe ( 'callback' , ( ) => {
199186 it ( 'callback (py)' , ( ) => {
200187 const py_f = require ( 'function.py' ) ;
@@ -227,6 +214,8 @@ describe('metacall', () => {
227214 // Receiving undefined from a function that returns nothing in Python
228215 assert . strictEqual ( py_f . function_pass ( ) , undefined ) ;
229216
217+ /* TODO: This fails because classes are not implemented in the NodeJS loader */
218+
230219 /* TODO: After the refactor of class/object support the following tests do not pass */
231220 /* Now the class returned by Python is threated as a TYPE_CLASS instead of a TYPE_PTR */
232221 /* Refactor this when there is support for class in NodeJS Loader */
@@ -242,7 +231,6 @@ describe('metacall', () => {
242231 assert.strictEqual(py_f.function_myclass_cb((klass) => py_f.function_myclass_method(klass)), 'hello world');
243232 assert.strictEqual(py_f.function_myclass_cb((klass) => py_f.function_myclass_method(klass)), 'hello world'); // Check for function lifetime
244233 */
245- /*
246234
247235 // Double recursion
248236 const sum = ( value , f ) => value <= 0 ? 0 : value + f ( value - 1 , sum ) ;
@@ -312,5 +300,4 @@ describe('metacall', () => {
312300 assert . strictEqual ( py_factorial ( 5 ) , 120 ) ;
313301 } ) ;
314302 } ) ;
315- */
316303} ) ;
0 commit comments