STO{+,-,/,*} follow semantic of rpn-2.4
This commit is contained in:
parent
92bd286f71
commit
9c29599fb7
2 changed files with 4 additions and 36 deletions
|
@ -55,34 +55,22 @@ module RplLang
|
|||
@dictionary.add_word( ['sto+'],
|
||||
'Store',
|
||||
'( a n -- ) add content to variable\'s value',
|
||||
Types.new_object( RplProgram, '« dup type "Name" ==
|
||||
« swap »
|
||||
ift
|
||||
over rcl + swap sto »' ) )
|
||||
Types.new_object( RplProgram, '« swap over rcl + swap sto »' ) )
|
||||
|
||||
@dictionary.add_word( ['sto-'],
|
||||
'Store',
|
||||
'( a n -- ) subtract content to variable\'s value',
|
||||
Types.new_object( RplProgram, '« dup type "Name" ==
|
||||
« swap »
|
||||
ift
|
||||
over rcl swap - swap sto »' ) )
|
||||
Types.new_object( RplProgram, '« swap over rcl swap - swap sto »' ) )
|
||||
|
||||
@dictionary.add_word( ['sto×', 'sto*'],
|
||||
'Store',
|
||||
'( a n -- ) multiply content of variable\'s value',
|
||||
Types.new_object( RplProgram, '« dup type "Name" ==
|
||||
« swap »
|
||||
ift
|
||||
over rcl * swap sto »' ) )
|
||||
Types.new_object( RplProgram, '« swap over rcl * swap sto »' ) )
|
||||
|
||||
@dictionary.add_word( ['sto÷', 'sto/'],
|
||||
'Store',
|
||||
'( a n -- ) divide content of variable\'s value',
|
||||
Types.new_object( RplProgram, '« dup type "Name" ==
|
||||
« swap »
|
||||
ift
|
||||
over rcl swap / swap sto »' ) )
|
||||
Types.new_object( RplProgram, '« swap over rcl swap / swap sto »' ) )
|
||||
|
||||
@dictionary.add_word( ['sneg'],
|
||||
'Store',
|
||||
|
|
|
@ -61,11 +61,6 @@ class TestLanguageStore < MiniTest::Test
|
|||
end
|
||||
|
||||
def test_sto_add
|
||||
interpreter = Rpl.new
|
||||
interpreter.run '1 \'test\' sto \'test\' 3 sto+ \'test\' rcl'
|
||||
assert_equal [Types.new_object( RplNumeric, 4 )],
|
||||
interpreter.stack
|
||||
|
||||
interpreter = Rpl.new
|
||||
interpreter.run '1 \'test\' sto 3 \'test\' sto+ \'test\' rcl'
|
||||
assert_equal [Types.new_object( RplNumeric, 4 )],
|
||||
|
@ -73,11 +68,6 @@ class TestLanguageStore < MiniTest::Test
|
|||
end
|
||||
|
||||
def test_sto_subtract
|
||||
interpreter = Rpl.new
|
||||
interpreter.run '1 \'test\' sto \'test\' 3 sto- \'test\' rcl'
|
||||
assert_equal [Types.new_object( RplNumeric, -2 )],
|
||||
interpreter.stack
|
||||
|
||||
interpreter = Rpl.new
|
||||
interpreter.run '1 \'test\' sto 3 \'test\' sto- \'test\' rcl'
|
||||
assert_equal [Types.new_object( RplNumeric, -2 )],
|
||||
|
@ -85,11 +75,6 @@ class TestLanguageStore < MiniTest::Test
|
|||
end
|
||||
|
||||
def test_sto_multiply
|
||||
interpreter = Rpl.new
|
||||
interpreter.run '2 \'test\' sto \'test\' 3 sto* \'test\' rcl'
|
||||
assert_equal [Types.new_object( RplNumeric, 6 )],
|
||||
interpreter.stack
|
||||
|
||||
interpreter = Rpl.new
|
||||
interpreter.run '2 \'test\' sto 3 \'test\' sto* \'test\' rcl'
|
||||
assert_equal [Types.new_object( RplNumeric, 6 )],
|
||||
|
@ -97,11 +82,6 @@ class TestLanguageStore < MiniTest::Test
|
|||
end
|
||||
|
||||
def test_sto_divide
|
||||
interpreter = Rpl.new
|
||||
interpreter.run '3 \'test\' sto \'test\' 2.0 sto÷ \'test\' rcl'
|
||||
assert_equal [Types.new_object( RplNumeric, 1.5 )],
|
||||
interpreter.stack
|
||||
|
||||
interpreter = Rpl.new
|
||||
interpreter.run '3 \'test\' sto 2.0 \'test\' sto÷ \'test\' rcl'
|
||||
assert_equal [Types.new_object( RplNumeric, 1.5 )],
|
||||
|
|
Loading…
Reference in a new issue