@@ -123,16 +123,33 @@ describe('metacall', () => {
123
123
assert . strictEqual ( asd . mixed_args ( 'a' , 3 , 4 , 3.4 , 'NOT IMPLEMENTED' ) , 65 ) ;
124
124
} ) ;
125
125
it ( 'require (py)' , ( ) => {
126
- // TODO: Both methods work, should we disable the commented out style to be NodeJS compilant?
127
- // const example = require('example.py');
128
- const example = require ( './example.py' ) ;
129
- assert . notStrictEqual ( example , undefined ) ;
130
- assert . strictEqual ( example . multiply ( 2 , 2 ) , 4 ) ;
131
- assert . strictEqual ( example . divide ( 4.0 , 2.0 ) , 2.0 ) ;
132
- assert . strictEqual ( example . sum ( 2 , 2 ) , 4 ) ;
133
- assert . strictEqual ( example . strcat ( '2' , '2' ) , '22' ) ;
134
- assert . deepStrictEqual ( example . return_array ( ) , [ 1 , 2 , 3 ] ) ;
135
- assert . deepStrictEqual ( example . return_same_array ( [ 1 , 2 , 3 ] ) , [ 1 , 2 , 3 ] ) ;
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'));
140
+ } ) ;
141
+ it ( 'require (py class)' , ( ) => {
142
+ const classname = require ( './classname.py' ) ;
143
+ assert . notStrictEqual ( classname . function_returns_object_new_local_variable , undefined ) ;
144
+ assert . notStrictEqual ( classname . return_bound_method_param , undefined ) ;
145
+ assert . notStrictEqual ( classname . return_object_function , undefined ) ;
146
+ assert . notStrictEqual ( classname . return_itself , undefined ) ;
147
+ assert . notStrictEqual ( classname . return_object_bound_method_call , undefined ) ;
148
+ assert . notStrictEqual ( classname . return_class_function , undefined ) ;
149
+ assert . notStrictEqual ( classname . return_object_bound_method_new_object , undefined ) ;
150
+
151
+ // TODO: Implement classes
152
+ // assert.notStrictEqual(classname.MyClass, undefined);
136
153
} ) ;
137
154
it ( 'require (py module)' , ( ) => {
138
155
// This code loads directly a module without extension from Python
@@ -145,11 +162,9 @@ describe('metacall', () => {
145
162
const { find_library } = require ( 'ctypes.util' ) ;
146
163
assert . notStrictEqual ( find_library , undefined ) ;
147
164
148
- // TODO: This fails because the submodule imports a class, which
149
- // is not yet supported by the NodeJS loader
150
- //const { py_encode_basestring_ascii } = require('json.encoder');
151
- //assert.notStrictEqual(py_encode_basestring_ascii, undefined);
152
- //assert.strictEqual(py_encode_basestring_ascii('asd'), '"asd"');
165
+ const { py_encode_basestring_ascii } = require ( 'json.encoder' ) ;
166
+ assert . notStrictEqual ( py_encode_basestring_ascii , undefined ) ;
167
+ assert . strictEqual ( py_encode_basestring_ascii ( 'asd' ) , '"asd"' ) ;
153
168
} ) ;
154
169
it ( 'require (rb)' , ( ) => {
155
170
// TODO: Both methods work, should we disable the commented out style to be NodeJS compilant?
0 commit comments