UG update; Enhance .gather error messages.

This commit is contained in:
Peter Camilleri 2015-07-28 13:26:52 -04:00
parent cf67bd8122
commit ba389ba08e
3 changed files with 7 additions and 6 deletions

Binary file not shown.

View file

@ -179,9 +179,11 @@ class ArrayLibraryTester < Minitest::Test
end
def test_gather
foorth_equal(' 1 2 3 gather', [[1,2,3]])
foorth_equal(' 1 2 3 3 .gather', [[1,2,3]])
foorth_equal('5 6 1 2 3 3 .gather', [5,6,[1,2,3]])
foorth_equal(' gather', [[]])
foorth_equal(' 1 2 3 gather', [[1,2,3]])
foorth_equal(' 1 2 3 3 .gather', [[1,2,3]])
foorth_equal('5 6 1 2 3 3 .gather', [5,6,[1,2,3]])
foorth_raises('5 6 1 2 3 -1 .gather')
foorth_raises('5 6 1 2 3 0 .gather')

View file

@ -251,9 +251,8 @@ module XfOOrth
#[ x0 x1 ... xN N] .gather [array]
Integer.create_shared_method('.gather', TosSpec, [], &lambda {|vm|
unless self > 0 && self <= vm.data_stack.length
error "F30: Invalid .gather count value."
end
error "F30: Invalid .gather count value." unless self > 0
error "F30: Data stack underflow." unless self <= vm.data_stack.length
temp = vm.data_stack.pop(self)
vm.data_stack << temp