You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
499 B
24 lines
499 B
2 years ago
|
require_relative "../test_helper"
|
||
|
|
||
|
require "lox/environment"
|
||
|
require "lox/error"
|
||
|
require "lox/token"
|
||
|
|
||
|
class TestEnvironment < Lox::Test
|
||
|
def setup
|
||
|
@env = Lox::Environment.new
|
||
|
end
|
||
|
|
||
|
def test_define
|
||
|
@env.define("name", "value")
|
||
|
|
||
|
assert_equal "value", @env.get(Lox::Token.new(:IDENTIFIER, "name", "name", 0))
|
||
|
end
|
||
|
|
||
|
def test_get
|
||
|
assert_raises Lox::RuntimeError, "Undefined variable name 'name'." do
|
||
|
@env.get(Lox::Token.new(:IDENTIFIER, "name", "name", 0))
|
||
|
end
|
||
|
end
|
||
|
end
|