noofakku 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +0 -1
- data/Gemfile.lock +1 -1
- data/README.md +40 -2
- data/lib/noofakku.rb +1 -0
- data/lib/noofakku/instruction/noop.rb +1 -1
- data/noofakku.gemspec +1 -1
- data/test/noofakku_smoke_test.rb +18 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZTgyZDdhYzM4YmQ4MzY3ZTMzMGVmYmY5MGZiNWRjNjcxZDhhM2Q1OQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MGJkM2Y4ZTgzZjY3YzFhNjM2NzhlMDEzNGU1ZDdiMmJlNjIzY2M3Mw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZTNmODAxNDY4YzY1NTQ4ZjFmMmIyOTU3ODU0NjgyNGNiYjE3ZTM0ZWQ4ZjUy
|
10
|
+
MjAxZTNkYjhkODRlMDUxZDk5MWZmNWYxYTIzMGE0YjcyOTFlM2IyYjIyNzNh
|
11
|
+
NDk4NTUwOTZjOWM4YzZiODhmNzU4M2MxNTRmZTU4M2JmZWEwYWI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTY5OTdjZWQzMjQxODQyNjIyMmU3ZDg5N2NlYjc2ODIwZDU0YTZiMjcwOWMz
|
14
|
+
ZjJlMmYzMDY2MTUwZjNkMjQ0YmIwZjdjZDdmMDIzODAwMGNiOTczN2ViZjc5
|
15
|
+
ZTIwYTg2MjkzYTZiZjlhNGFjYzkzMDExNDk1MDg4YmQxNGM2YzU=
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
Status
|
2
|
+
======
|
3
3
|
<a href="http://badge.fury.io/rb/noofakku"><img src="https://badge.fury.io/rb/noofakku@2x.png" alt="Gem Version" height='18'></a>
|
4
4
|
<br/>
|
5
5
|
<a href="https://travis-ci.org/mcodella/noofakku"><img src="https://travis-ci.org/mcodella/noofakku.png?branch=master" alt="Travis-CI Status" height='18'></a>
|
@@ -7,3 +7,41 @@ Noofakku
|
|
7
7
|
<a href="https://codeclimate.com/github/mcodella/noofakku"><img src="https://codeclimate.com/github/mcodella/noofakku.png" height='18'/></a>
|
8
8
|
<br/>
|
9
9
|
<a href='https://coveralls.io/r/mcodella/noofakku'><img src='https://coveralls.io/repos/mcodella/noofakku/badge.png' alt='Coverage Status' height='18'/></a>
|
10
|
+
|
11
|
+
Usage Sample
|
12
|
+
============
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
require 'noofakku'
|
16
|
+
|
17
|
+
input = -> { 0 }
|
18
|
+
produced = ''
|
19
|
+
output = ->value { produced << value }
|
20
|
+
|
21
|
+
# will print "Hello World!\n"
|
22
|
+
program = '++++++++++[>+++++++>++++++++++>+++>'
|
23
|
+
program << '+<<<<-]>++.>+.+++++++..+++.>++.<<++'
|
24
|
+
program << '+++++++++++++.>.+++.------.--------.>+.>.'
|
25
|
+
|
26
|
+
Noofakku::VM.start(program, input, output)
|
27
|
+
|
28
|
+
p produced #=> "Hello World!\n"
|
29
|
+
```
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
require 'noofakku'
|
33
|
+
|
34
|
+
to_be_sorted = [5, 3, 2, 6, 0].each
|
35
|
+
input = -> { to_be_sorted.next }
|
36
|
+
produced = []
|
37
|
+
output = ->value { produced << value }
|
38
|
+
|
39
|
+
# will sort the zero-ended array in input
|
40
|
+
program = '>>,[>>,]<< [[-<+<]>[>[>>]<[.[-]<[[>>+<<-]<]>>]>]<<]'
|
41
|
+
|
42
|
+
Noofakku::VM.start(program, input, output)
|
43
|
+
|
44
|
+
p produced #=> [2, 3, 5, 6]
|
45
|
+
```
|
46
|
+
|
47
|
+
Other usage samples can be found in https://github.com/mcodella/noofakku/blob/master/test/noofakku_smoke_test.rb
|
data/lib/noofakku.rb
CHANGED
data/noofakku.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'noofakku'
|
3
3
|
s.version = `git describe --tags --abbrev=0`.split("\n")[0]
|
4
|
-
s.date =
|
4
|
+
s.date = `date +"%Y-%m-%d"`
|
5
5
|
s.summary = "Noofakku"
|
6
6
|
s.description = "A simple brainfuck implementation"
|
7
7
|
s.authors = ["Mauro Codella"]
|
data/test/noofakku_smoke_test.rb
CHANGED
@@ -9,31 +9,31 @@ module Noofakku
|
|
9
9
|
context 'Execution' do
|
10
10
|
|
11
11
|
should 'produce "Hello World" in output' do
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
input = -> { 0 }
|
13
|
+
produced = ''
|
14
|
+
output = ->value { produced << value }
|
15
|
+
program = '++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.'
|
16
|
+
Noofakku::VM.start(program, input, output)
|
17
17
|
assert_equal "Hello World!\n", produced
|
18
18
|
end
|
19
19
|
|
20
20
|
should 'produce Fibonacci numbers in output' do
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
program = '+.>+.>>>++++++++++[<<<[->>+<<]>>[-<+<+>>]<<<[->+<]>>[-<<+>>]<.>>>-]'
|
22
|
+
input = -> { 0 }
|
23
|
+
produced = []
|
24
|
+
output = ->value { produced << value }
|
25
|
+
Noofakku::VM.start(program, input, output)
|
26
|
+
assert_equal [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144], produced
|
27
27
|
end
|
28
28
|
|
29
29
|
should 'order numbers in input' do
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
30
|
+
program = '>>,[>>,]<< [[-<+<]>[>[>>]<[.[-]<[[>>+<<-]<]>>]>]<<]'
|
31
|
+
to_be_sorted = [5, 3, 2, 6, 0].each
|
32
|
+
input = -> { to_be_sorted.next }
|
33
|
+
produced = []
|
34
|
+
output = ->value { produced << value }
|
35
|
+
Noofakku::VM.start(program, input, output)
|
36
|
+
assert_equal [2, 3, 5, 6], produced
|
37
37
|
end
|
38
38
|
|
39
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: noofakku
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mauro Codella
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|