Tab-completion in REPL based on module variables.

This commit is contained in:
Bob Nystrom
2016-05-22 15:32:17 -07:00
parent 98514188b0
commit f47e128978
8 changed files with 177 additions and 25 deletions

View 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

View File

@ -0,0 +1,3 @@
import "meta" for Meta
Meta.getModuleVariables(123) // expect runtime error: Module name must be a string.

View File

@ -0,0 +1,3 @@
import "meta" for Meta
Meta.getModuleVariables("unknown") // expect runtime error: Could not find a module named 'unknown'.