From b8f5f0935f1a440649c6c8523607ce4d832799e8 Mon Sep 17 00:00:00 2001 From: Peter Camilleri Date: Fri, 9 Jan 2015 15:47:53 -0500 Subject: [PATCH] Changed emit to .emit and corrected tests. --- integration/stdio_library_tests.rb | 9 ++++++--- lib/fOOrth/library/stdio_library.rb | 7 +++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/integration/stdio_library_tests.rb b/integration/stdio_library_tests.rb index 38b899a..9599837 100644 --- a/integration/stdio_library_tests.rb +++ b/integration/stdio_library_tests.rb @@ -38,10 +38,13 @@ class StdioLibraryTester < MiniTest::Unit::TestCase end def test_the_emit - foorth_output(' 65 emit', "A") - foorth_output('126 emit', "~") + foorth_output(' 65 .emit', "A") + foorth_output('126 .emit', "~") - foorth_utf8_output('255 emit', [195, 191]) + foorth_utf8_output('255 .emit', [195, 191]) + + foorth_output(' "A123" .emit', "A") + foorth_raises('1+1i .emit') end end diff --git a/lib/fOOrth/library/stdio_library.rb b/lib/fOOrth/library/stdio_library.rb index fda02fc..2968919 100644 --- a/lib/fOOrth/library/stdio_library.rb +++ b/lib/fOOrth/library/stdio_library.rb @@ -28,10 +28,13 @@ module XfOOrth VirtualMachine.create_shared_method('spaces', MacroSpec, [:macro, "print ' ' * vm.pop(); "]) - # Print out a single character. + #Print out a single character. #[obj] emit []; print out the object as a character. - Object.create_shared_method('emit', TosSpec, [], + Numeric.create_shared_method('.emit', TosSpec, [], &lambda {|vm| print self.to_foorth_c}) + String.create_shared_method('.emit', TosSpec, [], + &lambda {|vm| print self.to_foorth_c}) + Complex.create_shared_method('.emit', TosSpec, [:stub]) #Get a string from the console. # [] accept [string]; gets a string from the console.