Permalink
Browse files

added basic runtime.

We'll need more stuff later to keep track of loops, but...
  • Loading branch information...
1 parent 756f0e2 commit 83bb1b10efa26c7b3e82ebdeb06526a7f87ec6a9 @steveklabnik committed Dec 9, 2012
Showing with 30 additions and 0 deletions.
  1. +13 −0 lib/mojikun/runtime.rb
  2. +17 −0 test/runtime_test.rb
View
@@ -0,0 +1,13 @@
+module Mojikun
+ class Runtime
+ attr_reader :instruction_pointer,
+ :data_pointer,
+ :data
+
+ def initialize
+ @instruction_pointer = 0
+ @data_pointer = 0
+ @data = [0] * 30000 # original interpreter had 30,000 cells
+ end
+ end
+end
View
@@ -0,0 +1,17 @@
+require 'mojikun/runtime'
+
+require 'minitest/autorun'
+
+class RuntimeTest < MiniTest::Unit::TestCase
+ def test_instruction_pointer
+ assert_equal 0, Mojikun::Runtime.new.instruction_pointer
+ end
+
+ def test_data_pointer
+ assert_equal 0, Mojikun::Runtime.new.data_pointer
+ end
+
+ def test_data
+ assert_equal [0] * 30000, Mojikun::Runtime.new.data
+ end
+end

0 comments on commit 83bb1b1

Please sign in to comment.