mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-11 22:28:45 +01:00
Tab-completion in REPL based on module variables.
This commit is contained in:
17
test/meta/get_module_variables.wren
Normal file
17
test/meta/get_module_variables.wren
Normal file
@ -0,0 +1,17 @@
|
||||
import "meta" for Meta
|
||||
|
||||
var variables = Meta.getModuleVariables("main")
|
||||
|
||||
// Includes implicitly imported core stuff.
|
||||
System.print(variables.contains("Object")) // expect: true
|
||||
System.print(variables.contains("Bool")) // expect: true
|
||||
|
||||
// Includes top level variables.
|
||||
System.print(variables.contains("variables")) // expect: true
|
||||
|
||||
// Even ones declared later.
|
||||
System.print(variables.contains("later")) // expect: true
|
||||
|
||||
var later = "values"
|
||||
|
||||
System.print(variables.contains("unknown")) // expect: false
|
||||
3
test/meta/get_module_variables_not_string.wren
Normal file
3
test/meta/get_module_variables_not_string.wren
Normal file
@ -0,0 +1,3 @@
|
||||
import "meta" for Meta
|
||||
|
||||
Meta.getModuleVariables(123) // expect runtime error: Module name must be a string.
|
||||
3
test/meta/get_module_variables_unknown_module.wren
Normal file
3
test/meta/get_module_variables_unknown_module.wren
Normal file
@ -0,0 +1,3 @@
|
||||
import "meta" for Meta
|
||||
|
||||
Meta.getModuleVariables("unknown") // expect runtime error: Could not find a module named 'unknown'.
|
||||
Reference in New Issue
Block a user