2021-12-07 16:09:17 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-02-11 15:46:47 +01:00
|
|
|
module RplLang
|
2022-02-10 14:50:59 +01:00
|
|
|
module Core
|
2022-02-11 15:46:47 +01:00
|
|
|
module Test
|
|
|
|
def populate_dictionary
|
|
|
|
super
|
|
|
|
|
|
|
|
@dictionary.add_word( ['>'],
|
|
|
|
'Test',
|
|
|
|
'( a b -- t ) is a greater than b?',
|
|
|
|
proc do
|
|
|
|
args = stack_extract( %i[any any] )
|
|
|
|
|
|
|
|
@stack << { type: :boolean,
|
|
|
|
value: args[1][:value] > args[0][:value] }
|
|
|
|
end )
|
|
|
|
|
|
|
|
@dictionary.add_word( ['≥', '>='],
|
|
|
|
'Test',
|
|
|
|
'( a b -- t ) is a greater than or equal to b?',
|
|
|
|
proc do
|
|
|
|
args = stack_extract( %i[any any] )
|
|
|
|
|
|
|
|
@stack << { type: :boolean,
|
|
|
|
value: args[1][:value] >= args[0][:value] }
|
|
|
|
end )
|
|
|
|
|
|
|
|
@dictionary.add_word( ['<'],
|
|
|
|
'Test',
|
|
|
|
'( a b -- t ) is a less than b?',
|
|
|
|
proc do
|
|
|
|
args = stack_extract( %i[any any] )
|
|
|
|
|
|
|
|
@stack << { type: :boolean,
|
|
|
|
value: args[1][:value] < args[0][:value] }
|
|
|
|
end )
|
|
|
|
|
|
|
|
@dictionary.add_word( ['≤', '<='],
|
|
|
|
'Test',
|
|
|
|
'( a b -- t ) is a less than or equal to b?',
|
|
|
|
proc do
|
|
|
|
args = stack_extract( %i[any any] )
|
|
|
|
|
|
|
|
@stack << { type: :boolean,
|
|
|
|
value: args[1][:value] <= args[0][:value] }
|
|
|
|
end )
|
|
|
|
|
|
|
|
@dictionary.add_word( ['≠', '!='],
|
|
|
|
'Test',
|
|
|
|
'( a b -- t ) is a not equal to b',
|
|
|
|
proc do
|
|
|
|
args = stack_extract( %i[any any] )
|
|
|
|
|
|
|
|
@stack << { type: :boolean,
|
|
|
|
value: args[1][:value] != args[0][:value] }
|
|
|
|
end )
|
|
|
|
|
|
|
|
@dictionary.add_word( ['==', 'same'],
|
|
|
|
'Test',
|
|
|
|
'( a b -- t ) is a equal to b',
|
|
|
|
proc do
|
|
|
|
args = stack_extract( %i[any any] )
|
|
|
|
|
|
|
|
@stack << { type: :boolean,
|
|
|
|
value: args[1][:value] == args[0][:value] }
|
|
|
|
end )
|
|
|
|
|
|
|
|
@dictionary.add_word( ['and'],
|
|
|
|
'Test',
|
|
|
|
'( a b -- t ) boolean and',
|
|
|
|
proc do
|
|
|
|
args = stack_extract( [%i[boolean], %i[boolean]] )
|
|
|
|
|
|
|
|
@stack << { type: :boolean,
|
|
|
|
value: args[1][:value] && args[0][:value] }
|
|
|
|
end )
|
|
|
|
|
|
|
|
@dictionary.add_word( ['or'],
|
|
|
|
'Test',
|
|
|
|
'( a b -- t ) boolean or',
|
|
|
|
proc do
|
|
|
|
args = stack_extract( [%i[boolean], %i[boolean]] )
|
|
|
|
|
|
|
|
@stack << { type: :boolean,
|
|
|
|
value: args[1][:value] || args[0][:value] }
|
|
|
|
end )
|
|
|
|
|
|
|
|
@dictionary.add_word( ['xor'],
|
|
|
|
'Test',
|
|
|
|
'( a b -- t ) boolean xor',
|
|
|
|
proc do
|
|
|
|
args = stack_extract( [%i[boolean], %i[boolean]] )
|
|
|
|
|
|
|
|
@stack << { type: :boolean,
|
|
|
|
value: args[1][:value] ^ args[0][:value] }
|
|
|
|
end )
|
|
|
|
|
|
|
|
@dictionary.add_word( ['not'],
|
|
|
|
'Test',
|
|
|
|
'( a -- t ) invert boolean value',
|
|
|
|
proc do
|
|
|
|
args = stack_extract( [%i[boolean]] )
|
|
|
|
|
|
|
|
@stack << { type: :boolean,
|
|
|
|
value: !args[0][:value] }
|
|
|
|
end )
|
|
|
|
|
|
|
|
@dictionary.add_word( ['true'],
|
|
|
|
'Test',
|
|
|
|
'( -- t ) push true onto stack',
|
|
|
|
proc do
|
|
|
|
@stack << { type: :boolean,
|
|
|
|
value: true }
|
2022-02-15 17:06:19 +01:00
|
|
|
end )
|
2022-02-11 15:46:47 +01:00
|
|
|
|
|
|
|
@dictionary.add_word( ['false'],
|
|
|
|
'Test',
|
|
|
|
'( -- t ) push false onto stack',
|
|
|
|
proc do
|
|
|
|
@stack << { type: :boolean,
|
|
|
|
value: false }
|
2022-02-15 17:06:19 +01:00
|
|
|
end )
|
2022-02-11 15:46:47 +01:00
|
|
|
end
|
2021-11-24 16:09:57 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|