forked from Mirror/wren
Get logical imports in "wren_modules" working.
There's a lot of changes here and surely some rough edges to iron out. Also, I need to update the docs. But I want to get closer to landing this so I can build on it.
This commit is contained in:
@ -1,3 +1,3 @@
|
||||
class Foo {
|
||||
foreign someUnknownMethod // expect runtime error: Could not find foreign method 'someUnknownMethod' for class Foo in module 'test/language/foreign/unknown_method'.
|
||||
foreign someUnknownMethod // expect runtime error: Could not find foreign method 'someUnknownMethod' for class Foo in module './test/language/foreign/unknown_method'.
|
||||
}
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
System.print("before") // expect: before
|
||||
import "./module" for Module // expect runtime error: Could not compile module 'test/language/module/compile_error/module'.
|
||||
import "./module" for Module // expect runtime error: Could not compile module './test/language/module/compile_error/module'.
|
||||
|
||||
6
test/language/module/logical_dir/logical_dir.wren
Normal file
6
test/language/module/logical_dir/logical_dir.wren
Normal file
@ -0,0 +1,6 @@
|
||||
// Import a module from within a named package.
|
||||
import "foo/within_foo" for Foo
|
||||
// expect: ran foo module
|
||||
// expect: ran bar module
|
||||
|
||||
System.print(Foo) // expect: from foo
|
||||
@ -0,0 +1,5 @@
|
||||
// nontest
|
||||
var Bar = "from bar"
|
||||
System.print("ran bar module")
|
||||
|
||||
import "foo/within_foo"
|
||||
@ -0,0 +1,5 @@
|
||||
// nontest
|
||||
var Foo = "from foo"
|
||||
System.print("ran foo module")
|
||||
|
||||
import "bar/within_bar"
|
||||
5
test/language/module/logical_short/logical_short.wren
Normal file
5
test/language/module/logical_short/logical_short.wren
Normal file
@ -0,0 +1,5 @@
|
||||
// Import a module whose name is the same as the package.
|
||||
import "foo" for Module
|
||||
// expect: ran module
|
||||
|
||||
System.print(Module) // expect: from module
|
||||
@ -0,0 +1,3 @@
|
||||
// nontest
|
||||
var Module = "from module"
|
||||
System.print("ran module")
|
||||
@ -1 +1 @@
|
||||
import "./does_not_exist" for DoesNotExist // expect runtime error: Could not load module 'test/language/module/does_not_exist'.
|
||||
import "./does_not_exist" for DoesNotExist // expect runtime error: Could not load module './test/language/module/does_not_exist'.
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
// Should execute the module:
|
||||
// expect: ran module
|
||||
import "./module" for DoesNotExist // expect runtime error: Could not find a variable named 'DoesNotExist' in module 'test/language/module/unknown_variable/module'.
|
||||
import "./module" for DoesNotExist // expect runtime error: Could not find a variable named 'DoesNotExist' in module './test/language/module/unknown_variable/module'.
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
// Stops as soon as it finds a wren_modules directory, regardless of whether or
|
||||
// not it contains the desired module.
|
||||
import "foo" // expect runtime error: Could not load module 'foo'.
|
||||
@ -0,0 +1,2 @@
|
||||
// nontest
|
||||
System.print("ran foo module")
|
||||
@ -0,0 +1,3 @@
|
||||
// Walk up parent directories from the root script to find "wren_modules".
|
||||
import "foo"
|
||||
// expect: ran foo module
|
||||
@ -0,0 +1,2 @@
|
||||
// nontest
|
||||
System.print("ran foo module")
|
||||
Reference in New Issue
Block a user