mirror of
https://github.com/erg-lang/erg.git
synced 2025-10-02 05:31:11 +00:00
27 lines
662 B
Python
27 lines
662 B
Python
unsound = import "unsound"
|
|
|
|
erg_compiler = pyimport "erg_compiler"
|
|
erg_parser = pyimport "erg_compiler/erg_parser"
|
|
erg_ast = pyimport "erg_compiler/erg_parser/ast"
|
|
|
|
mod = erg_parser.parse ".i = 1"
|
|
ast = erg_ast.AST.new "test", mod
|
|
test = erg_compiler.exec_ast ast
|
|
i = test.__dict__.get("i")
|
|
assert i in Int
|
|
assert i == 1
|
|
|
|
test2 = erg_compiler.exec ".i = 1"
|
|
i2 = test2.__dict__.get("i")
|
|
assert i2 in Int
|
|
assert i2 == i
|
|
|
|
a11y = erg_compiler.__import__ "examples/a11y"
|
|
pub = a11y.__dict__.get("public")
|
|
assert pub in Str
|
|
assert pub == "this is a public variable"
|
|
|
|
code = erg_compiler.compile "1 + 1", "eval"
|
|
i3 = unsound.pyeval code
|
|
assert i3 in Int
|
|
assert i3 == 2
|