brain_love 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  *.gem
2
2
  *.rbc
3
+ .rbx
3
4
  .bundle
4
5
  .config
5
6
  .yardoc
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - jruby-19mode
5
+ # - rbx-19mode
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ ## v0.0.2
4
+
5
+ * Data cells now are unsigned byte and wrap around on decrement and increment
6
+
7
+ ## v0.0.1
8
+
9
+ * Beginning of fun
data/README.md CHANGED
@@ -21,10 +21,12 @@ Or from file:
21
21
 
22
22
  ### In your code
23
23
 
24
- require 'brain_love'
24
+ ```ruby
25
+ require 'brain_love'
25
26
 
26
- # Hello World
27
- BrainLove.run_string('>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.>>>++++++++[<++++>-]<.>>>++++++++++[<+++++++++>-]<---.<<<<.+++.------.--------.>>+.')
27
+ # Hello World
28
+ BrainLove.run_string('>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.>>>++++++++[<++++>-]<.>>>++++++++++[<+++++++++>-]<---.<<<<.+++.------.--------.>>+.')
29
+ ```
28
30
 
29
31
  ## Portability
30
32
 
data/bin/brain_love CHANGED
@@ -29,5 +29,5 @@ end
29
29
  if code = options[:execute]
30
30
  BrainLove.run_string(code)
31
31
  elsif !ARGV.empty? && options[:execute].nil?
32
- ARGV.each { |_| BrainLove.run_file(_) }
32
+ ARGV.each { |file| BrainLove.run_file(file) }
33
33
  end
data/brain_love.gemspec CHANGED
@@ -16,5 +16,6 @@ Gem::Specification.new do |gem|
16
16
  gem.version = BrainLove::VERSION
17
17
 
18
18
  gem.add_development_dependency "rspec"
19
+ gem.add_development_dependency "rake"
19
20
  gem.add_runtime_dependency "parslet"
20
21
  end
@@ -1,3 +1,3 @@
1
1
  module BrainLove
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/brain_love/vm.rb CHANGED
@@ -66,8 +66,10 @@ module BrainLove
66
66
  when DEC_DP
67
67
  @dp -= 1
68
68
  when INC_BYTE
69
+ @data[@dp] = 0 if @data[@dp] == 255
69
70
  @data[@dp] += 1
70
71
  when DEC_BYTE
72
+ @data[@dp] = 256 if @data[@dp] == 0
71
73
  @data[@dp] -= 1
72
74
  when PUTC
73
75
  @output.putc(@data[@dp].chr)
@@ -40,6 +40,12 @@ describe BrainLove::VM do
40
40
  it "increments the byte at the pointer by one" do
41
41
  expect { vm.execute }.to change { vm.data[1] }.by(1)
42
42
  end
43
+
44
+ it "wraps around value" do
45
+ code = Array.new(256, BrainLove::VM::INC_BYTE).map(&:chr).join
46
+ vm = BrainLove::VM.new(code, input, output)
47
+ expect { vm.execute }.to change { vm.data[0] }.by(1)
48
+ end
43
49
  end
44
50
 
45
51
  describe "DEC_BYTE" do
@@ -48,6 +54,12 @@ describe BrainLove::VM do
48
54
  it "decrements the byte at the pointer by one" do
49
55
  expect { vm.execute }.to change { vm.data[1] }.by(1)
50
56
  end
57
+
58
+ it "wraps around value" do
59
+ code = BrainLove::VM::DEC_BYTE.chr
60
+ vm = BrainLove::VM.new(code, input, output)
61
+ expect { vm.execute }.to change { vm.data[0] }.by(255)
62
+ end
51
63
  end
52
64
 
53
65
  describe "PUTC" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brain_love
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-07 00:00:00.000000000 Z
12
+ date: 2012-04-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -27,6 +27,22 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
30
46
  - !ruby/object:Gem::Dependency
31
47
  name: parslet
32
48
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +68,8 @@ extensions: []
52
68
  extra_rdoc_files: []
53
69
  files:
54
70
  - .gitignore
71
+ - .travis.yml
72
+ - CHANGELOG.md
55
73
  - Gemfile
56
74
  - LICENSE
57
75
  - README.md