@@ -46,16 +46,16 @@ describe('metacall', () => {
4646 it ( 'metacall_load_from_file (py)' , ( ) => {
4747 assert . strictEqual ( metacall_load_from_file ( 'py' , [ 'helloworld.py' ] ) , undefined ) ;
4848
49- const script = metacall_handle ( 'py' , 'helloworld' ) ;
49+ const script = metacall_handle ( 'py' , 'helloworld.py ' ) ;
5050 assert . notStrictEqual ( script , undefined ) ;
51- assert . strictEqual ( script . name , 'helloworld' ) ;
51+ assert . strictEqual ( script . name , 'helloworld.py ' ) ;
5252 } ) ;
5353 it ( 'metacall_load_from_file (rb)' , ( ) => {
5454 assert . strictEqual ( metacall_load_from_file ( 'rb' , [ 'ducktype.rb' ] ) , undefined ) ;
5555
56- const script = metacall_handle ( 'rb' , 'ducktype' ) ;
56+ const script = metacall_handle ( 'rb' , 'ducktype.rb ' ) ;
5757 assert . notStrictEqual ( script , undefined ) ;
58- assert . strictEqual ( script . name , 'ducktype' ) ;
58+ assert . strictEqual ( script . name , 'ducktype.rb ' ) ;
5959 } ) ;
6060 it ( 'metacall_load_from_memory (py)' , ( ) => {
6161 assert . strictEqual ( metacall_load_from_memory ( 'py' , 'def py_memory():\n\treturn 4;\n' ) , undefined ) ;
@@ -95,6 +95,18 @@ describe('metacall', () => {
9595 assert . deepStrictEqual ( example . return_array ( ) , [ 1 , 2 , 3 ] ) ;
9696 assert . deepStrictEqual ( example . return_same_array ( [ 1 , 2 , 3 ] ) , [ 1 , 2 , 3 ] ) ;
9797 } ) ;
98+ it ( 'require (py module)' , ( ) => {
99+ // This code loads directly a module without extension from Python
100+ const { loads } = require ( 'json' ) ;
101+ assert . notStrictEqual ( loads , undefined ) ;
102+ assert . deepStrictEqual ( loads ( '["foo", "bar"]' ) , [ 'foo' , 'bar' ] ) ;
103+ } ) ;
104+ it ( 'require (py submodule)' , ( ) => {
105+ // This code loads directly a module without extension from Python
106+ const { py_encode_basestring_ascii } = require ( 'json.encoder' ) ;
107+ assert . notStrictEqual ( py_encode_basestring_ascii , undefined ) ;
108+ assert . strictEqual ( py_encode_basestring_ascii ( 'asd' ) , '"asd"' ) ;
109+ } ) ;
98110 it ( 'require (rb)' , ( ) => {
99111 const cache = require ( 'cache.rb' ) ;
100112 assert . notStrictEqual ( cache , undefined ) ;
0 commit comments