fix eval'ing :string
This commit is contained in:
parent
eb7c3a3d73
commit
dec32d7f9b
3 changed files with 12 additions and 9 deletions
|
@ -12,7 +12,7 @@ module RplLang
|
|||
proc do
|
||||
args = stack_extract( [:any] )
|
||||
|
||||
if %i[list string numeric boolean].include?( args[0][:type] )
|
||||
if %i[list numeric boolean].include?( args[0][:type] )
|
||||
@stack << args[0] # these types evaluate to themselves
|
||||
else
|
||||
run( args[0][:value].to_s )
|
||||
|
|
|
@ -8,15 +8,9 @@ require 'rpl'
|
|||
class TestLanguageFileSystem < MiniTest::Test
|
||||
def test_fread
|
||||
interpreter = Rpl.new
|
||||
interpreter.run '"spec/test.rpl" fread'
|
||||
interpreter.run '"./spec/test.rpl" fread'
|
||||
|
||||
assert_equal [{ value: "1 2 +
|
||||
|
||||
« dup dup * * »
|
||||
'trrr' sto
|
||||
|
||||
trrr
|
||||
", type: :string }],
|
||||
assert_equal [{:type=>:string, :value=>"1 2 +\n\n« dup dup * * »\n'trrr' sto\n\ntrrr\n"}],
|
||||
interpreter.stack
|
||||
|
||||
interpreter.run 'eval vars'
|
||||
|
|
|
@ -16,6 +16,15 @@ class TestLanguageProgram < MiniTest::Test
|
|||
interpreter = Rpl.new
|
||||
interpreter.run '4 \'dup\' eval'
|
||||
|
||||
assert_equal [{ value: 4, type: :numeric, base: 10 },
|
||||
{ value: 4, type: :numeric, base: 10 }],
|
||||
interpreter.stack
|
||||
|
||||
interpreter = Rpl.new
|
||||
interpreter.run '4
|
||||
\'dup\'
|
||||
eval'
|
||||
|
||||
assert_equal [{ value: 4, type: :numeric, base: 10 },
|
||||
{ value: 4, type: :numeric, base: 10 }],
|
||||
interpreter.stack
|
||||
|
|
Loading…
Reference in a new issue