pocketlang/tests/lang/import.pk
Thakee Nathees 29be68fc86 classes were removed temproarly
to implement classes properly and support methods I had to remove
the older class syntax temproarly.
2022-04-20 13:54:45 +05:30

46 lines
1.2 KiB
Plaintext

## Testing import statement
import lang
import lang, path
import lang as o, path as p
from lang import write
from lang import clock as c
from lang import *
from path import *
import "basics.pk" ## will import all
import "controlflow.pk" as if_test
from "functions.pk" import f1, f2 as fn2, f3
## If it has a module name it'll bind to that name.
import 'import/module.pk'
assert(module_name.get_module_name() == 'module_name')
## Import everything from the module.
from 'import/module.pk' import *
assert(module_name.get_module_name == get_module_name)
## script without module name will import all by default.
import 'import/all_import.pk'
assert(all_f1() == 'f1')
assert(all_f2() == 'f2')
assert(all_f3() == 'f3')
## Import the script and bound it with a given name.
import 'import/all_import.pk' as all_import
assert(all_import.all_f1 == all_f1)
## Test if the imported globals were initialized
import 'import/globals.pk'
assert(g_import != null)
assert(g_import.g_var_1 == 3)
assert(g_import.g_var_2 == g_import.get_a_value())
import 'import/globals2.pk'
assert(g_val_1 == 100)
assert(g_val_2 == get_a_value())
# If we got here, that means all test were passed.
print('All TESTS PASSED')