diff --git a/kuroko.c b/kuroko.c index b5d9a51..802cd1e 100644 --- a/kuroko.c +++ b/kuroko.c @@ -204,7 +204,7 @@ int main(int argc, char * argv[]) { * collect the result of the last one and use it as the * exit code if it's an integer. */ for (int i = optind; i < argc; ++i) { - KrkValue out = krk_runfile(argv[i],1,"",argv[i]); + KrkValue out = krk_runfile(argv[i],1,"__main__",argv[i]); if (i + 1 == argc) result = out; } } diff --git a/test/testImportContext.krk.expect b/test/testImportContext.krk.expect new file mode 100644 index 0000000..e29b7b5 --- /dev/null +++ b/test/testImportContext.krk.expect @@ -0,0 +1 @@ +Hello, world: dummy I am a module. diff --git a/test/testModuleName.krk b/test/testModuleName.krk new file mode 100644 index 0000000..93945d3 --- /dev/null +++ b/test/testModuleName.krk @@ -0,0 +1,4 @@ +if __name__ == '__main__': + print("You called me directly!") +else: + print("My name is",__name__,"so I must have been imported.") diff --git a/test/testModuleName.krk.expect b/test/testModuleName.krk.expect new file mode 100644 index 0000000..13f7d15 --- /dev/null +++ b/test/testModuleName.krk.expect @@ -0,0 +1 @@ +You called me directly!