Allow multiple exports.

This commit is contained in:
Stephen Chung
2020-11-09 14:38:33 +08:00
parent 173f8474d6
commit 821e64adc4
8 changed files with 43 additions and 38 deletions

View File

@@ -248,7 +248,7 @@ fn test_module_from_ast() -> Result<(), Box<EvalAltResult>> {
import "another module" as extra;
// Variables defined at global level become module variables
const x = 123;
export const x = 123;
let foo = 41;
let hello;
@@ -258,6 +258,7 @@ fn test_module_from_ast() -> Result<(), Box<EvalAltResult>> {
export
x as abc,
x as xxx,
foo,
hello;
"#,
@@ -275,6 +276,14 @@ fn test_module_from_ast() -> Result<(), Box<EvalAltResult>> {
engine.eval::<INT>(r#"import "testing" as ttt; ttt::abc"#)?,
123
);
assert_eq!(
engine.eval::<INT>(r#"import "testing" as ttt; ttt::x"#)?,
123
);
assert_eq!(
engine.eval::<INT>(r#"import "testing" as ttt; ttt::xxx"#)?,
123
);
assert_eq!(
engine.eval::<INT>(r#"import "testing" as ttt; ttt::foo"#)?,
42