nydp 0.1.13.2 → 0.1.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lisp/core-010-precompile.nydp +7 -10
- data/lib/lisp/core-060-benchmarking.nydp +30 -7
- data/lib/lisp/tests/unparse-tests.nydp +2 -0
- data/lib/nydp/assignment.rb +3 -2
- data/lib/nydp/builtin/ensuring.rb +2 -1
- data/lib/nydp/builtin/handle_error.rb +2 -1
- data/lib/nydp/cond.rb +7 -5
- data/lib/nydp/function_invocation.rb +16 -12
- data/lib/nydp/interpreted_function.rb +12 -7
- data/lib/nydp/pair.rb +2 -6
- data/lib/nydp/symbol.rb +2 -1
- data/lib/nydp/symbol_lookup.rb +1 -1
- data/lib/nydp/version.rb +1 -1
- data/lib/nydp/vm.rb +4 -11
- data/spec/date_spec.rb +9 -9
- data/spec/foreign_hash_spec.rb +7 -7
- data/spec/hash_non_hash_behaviour_spec.rb +4 -4
- data/spec/hash_spec.rb +8 -8
- data/spec/pair_spec.rb +1 -1
- data/spec/string_atom_spec.rb +4 -4
- data/spec/symbol_spec.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4934e2de2e4ae2558056bd67df1bfb85e8285d80
|
4
|
+
data.tar.gz: 591950ecbf8f0d76ef6e7afd79a48138bb7164b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3efdac8cdb5dfdc6cf6908e2d4950430769d888af64252a2153c05e06d25dff99a47be81d48e36478a1716327d2544ad78f76bff7a9a7f7e717b3ba564a4dda
|
7
|
+
data.tar.gz: 13cb1296116e684380b86b0f887b13ca2b22aef929ce933429ad74f5d49d40f151cd5095ecb96eb934e57d0c94755f3f9cc55eb9377f9b8dc749dd98f3d89cca
|
@@ -1,18 +1,17 @@
|
|
1
1
|
|
2
|
-
(assign mac-expand (fn (names macfn
|
2
|
+
(assign mac-expand (fn (names macfn expr)
|
3
3
|
(cond macfn
|
4
4
|
(pre-compile-with names
|
5
|
-
(apply macfn
|
6
|
-
|
5
|
+
(apply macfn (cdr expr)))
|
6
|
+
expr)))
|
7
7
|
|
8
8
|
(assign macs (hash))
|
9
9
|
|
10
10
|
(assign pre-compile-expr
|
11
|
-
(fn (names
|
11
|
+
(fn (names expr)
|
12
12
|
(mac-expand names
|
13
|
-
(hash-get names
|
14
|
-
|
15
|
-
body)))
|
13
|
+
(hash-get names (car expr))
|
14
|
+
expr)))
|
16
15
|
|
17
16
|
(assign pre-compile-each
|
18
17
|
(fn (names args)
|
@@ -35,9 +34,7 @@
|
|
35
34
|
(cond (eq? (car arg) 'quote)
|
36
35
|
arg
|
37
36
|
(pre-compile-each names
|
38
|
-
(pre-compile-expr names
|
39
|
-
(car arg)
|
40
|
-
(cdr arg))))
|
37
|
+
(pre-compile-expr names arg)))
|
41
38
|
arg)))
|
42
39
|
|
43
40
|
(assign pre-compile-debug
|
@@ -34,13 +34,36 @@
|
|
34
34
|
(bm-complicated-0 * 3 (bm-complicated-0 + 3 6))
|
35
35
|
(bm-complicated-0 - 10 (bm-complicated-0 - 13 8))))
|
36
36
|
|
37
|
+
(def bm-pre-compile-test ()
|
38
|
+
(for i 1 10
|
39
|
+
(pre-compile (dox-src rbs))))
|
40
|
+
|
41
|
+
(def bm-hash-fill
|
42
|
+
(let h {}
|
43
|
+
(=h.aa 1) (=h.ab 2) (=h.ac 3) (=h.ba 4) (=h.bb 5) (=h.bc 6)
|
44
|
+
(=h.ca 1) (=h.cb 2) (=h.cc 3) (=h.ca 4) (=h.cb 5) (=h.cc 6)
|
45
|
+
(=h.da 1) (=h.db 2) (=h.dc 3) (=h.da 4) (=h.db 5) (=h.dc 6)
|
46
|
+
(=h.aa 1) (=h.ab 2) (=h.ac 3) (=h.ba 4) (=h.bb 5) (=h.bc 6)
|
47
|
+
(=h.ca 1) (=h.cb 2) (=h.cc 3) (=h.ca 4) (=h.cb 5) (=h.cc 6)
|
48
|
+
(=h.da 1) (=h.db 2) (=h.dc 3) (=h.da 4) (=h.db 5) (=h.dc 6)
|
49
|
+
(list (list h.aa h.ab h.ac h.ba h.bb h.bc)
|
50
|
+
(list h.aa h.ab h.ac h.ba h.bb h.bc)
|
51
|
+
(list h.ca h.cb h.cc h.ca h.cb h.cc)
|
52
|
+
(list h.da h.db h.dc h.da h.db h.dc)
|
53
|
+
(list h.aa h.ab h.ac h.ba h.bb h.bc)
|
54
|
+
(list h.ca h.cb h.cc h.ca h.cb h.cc)
|
55
|
+
(list h.da h.db h.dc h.da h.db h.dc)
|
56
|
+
(list h.da h.ab h.ac h.ba h.bb h.bc))))
|
57
|
+
|
37
58
|
(def rbs (name)
|
38
59
|
(let summary nil
|
39
|
-
(push (bm "pythag " bm-pythag
|
40
|
-
(push (bm "recursive " bm-complicated
|
41
|
-
(push (bm "0 arg times" bm-0-arg-times-call
|
42
|
-
(push (bm "1 arg times" bm-1-arg-times-call
|
43
|
-
(push (bm "2 arg times" bm-2-arg-times-call
|
44
|
-
(push (bm "3 arg times" bm-3-arg-times-call
|
45
|
-
(push (bm "4 arg times" bm-4-arg-times-call
|
60
|
+
;; (push (bm "pythag " bm-pythag 5 10) summary)
|
61
|
+
;; (push (bm "recursive " bm-complicated 5 1000) summary)
|
62
|
+
;; (push (bm "0 arg times" bm-0-arg-times-call 5 1000) summary)
|
63
|
+
;; (push (bm "1 arg times" bm-1-arg-times-call 5 1000) summary)
|
64
|
+
;; (push (bm "2 arg times" bm-2-arg-times-call 5 1000) summary)
|
65
|
+
;; (push (bm "3 arg times" bm-3-arg-times-call 5 1000) summary)
|
66
|
+
;; (push (bm "4 arg times" bm-4-arg-times-call 5 1000) summary)
|
67
|
+
;; (push (bm "pre-compile" bm-pre-compile-test 10 10000) summary)
|
68
|
+
(push (bm "hashing" bm-hash-fill 10 200000) summary)
|
46
69
|
(each s summary (p name " " s))))
|
@@ -3,4 +3,6 @@
|
|
3
3
|
("quote" (to-string '(quote a)) "'a" )
|
4
4
|
("quasiquote" (to-string '(quasiquote a)) "`a" )
|
5
5
|
("unquote-splicing" (to-string '(unquote-splicing a)) ",@a" )
|
6
|
+
("brace-list" (to-string '(brace-list a)) "{ a }" )
|
7
|
+
("brace-list" (to-string '(brace-list a b)) "{ a b }" )
|
6
8
|
("brace-list" (to-string '(brace-list a b c d)) "{ a b c d }" ))
|
data/lib/nydp/assignment.rb
CHANGED
@@ -5,7 +5,7 @@ module Nydp
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def execute vm
|
8
|
-
@name.assign vm.peek_arg, vm.
|
8
|
+
@name.assign vm.peek_arg, vm.current_context
|
9
9
|
end
|
10
10
|
|
11
11
|
def to_s
|
@@ -36,7 +36,8 @@ module Nydp
|
|
36
36
|
def inspect; to_s ; end
|
37
37
|
|
38
38
|
def execute vm
|
39
|
-
vm.
|
39
|
+
vm.instructions.push @instructions
|
40
|
+
vm.contexts.push vm.current_context
|
40
41
|
end
|
41
42
|
end
|
42
43
|
end
|
@@ -21,7 +21,8 @@ class Nydp::Builtin::Ensuring
|
|
21
21
|
fn_tricky = args.cdr.car
|
22
22
|
|
23
23
|
protection_instructions = Nydp::Pair.from_list [InvokeProtection.new(fn_ensure), Nydp::PopArg]
|
24
|
-
vm.
|
24
|
+
vm.instructions.push protection_instructions
|
25
|
+
vm.contexts.push vm.current_context
|
25
26
|
|
26
27
|
fn_tricky.invoke vm, Nydp.NIL
|
27
28
|
end
|
@@ -33,7 +33,8 @@ class Nydp::Builtin::HandleError
|
|
33
33
|
fn_tricky = args.cdr.car
|
34
34
|
|
35
35
|
catcher_instructions = Nydp::Pair.from_list [CatchError.new(fn_handle, vm.args.size)]
|
36
|
-
vm.
|
36
|
+
vm.instructions.push catcher_instructions
|
37
|
+
vm.contexts.push vm.current_context
|
37
38
|
|
38
39
|
fn_tricky.invoke vm, Nydp.NIL
|
39
40
|
end
|
data/lib/nydp/cond.rb
CHANGED
@@ -8,9 +8,9 @@ module Nydp
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def execute vm
|
11
|
-
|
12
|
-
truth
|
13
|
-
vm.
|
11
|
+
truth = !Nydp.NIL.is?(vm.args.pop)
|
12
|
+
vm.instructions.push (truth ? when_true : when_false)
|
13
|
+
vm.contexts.push vm.current_context
|
14
14
|
end
|
15
15
|
|
16
16
|
def inspect
|
@@ -31,8 +31,10 @@ module Nydp
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def execute vm
|
34
|
-
vm.
|
35
|
-
vm.
|
34
|
+
vm.instructions.push conditional
|
35
|
+
vm.contexts.push vm.current_context
|
36
|
+
vm.instructions.push condition
|
37
|
+
vm.contexts.push vm.current_context
|
36
38
|
end
|
37
39
|
|
38
40
|
def inspect
|
@@ -30,7 +30,7 @@ module Nydp
|
|
30
30
|
|
31
31
|
class Invocation_1 < Invocation::Base
|
32
32
|
def execute vm
|
33
|
-
f = vm.
|
33
|
+
f = vm.args.pop
|
34
34
|
f.invoke_1 vm
|
35
35
|
rescue Exception => e
|
36
36
|
handle e, f, Nydp.NIL
|
@@ -39,8 +39,9 @@ module Nydp
|
|
39
39
|
|
40
40
|
class Invocation_2 < Invocation::Base
|
41
41
|
def execute vm
|
42
|
-
arg = vm.
|
43
|
-
f
|
42
|
+
arg = vm.args.pop
|
43
|
+
f = vm.args.pop
|
44
|
+
|
44
45
|
f.invoke_2 vm, arg
|
45
46
|
rescue Exception => e
|
46
47
|
handle e, f, cons(arg)
|
@@ -49,9 +50,9 @@ module Nydp
|
|
49
50
|
|
50
51
|
class Invocation_3 < Invocation::Base
|
51
52
|
def execute vm
|
52
|
-
arg_1 = vm.
|
53
|
-
arg_0 = vm.
|
54
|
-
f = vm.
|
53
|
+
arg_1 = vm.args.pop
|
54
|
+
arg_0 = vm.args.pop
|
55
|
+
f = vm.args.pop
|
55
56
|
f.invoke_3 vm, arg_0, arg_1
|
56
57
|
rescue Exception => e
|
57
58
|
handle e, f, cons(arg_0, cons(arg_1))
|
@@ -60,10 +61,10 @@ module Nydp
|
|
60
61
|
|
61
62
|
class Invocation_4 < Invocation::Base
|
62
63
|
def execute vm
|
63
|
-
arg_2 = vm.
|
64
|
-
arg_1 = vm.
|
65
|
-
arg_0 = vm.
|
66
|
-
f = vm.
|
64
|
+
arg_2 = vm.args.pop
|
65
|
+
arg_1 = vm.args.pop
|
66
|
+
arg_0 = vm.args.pop
|
67
|
+
f = vm.args.pop
|
67
68
|
f.invoke_4 vm, arg_0, arg_1, arg_2
|
68
69
|
rescue Exception => e
|
69
70
|
handle e, f, cons(arg_0, cons(arg_1, cons(arg_2)))
|
@@ -87,6 +88,7 @@ module Nydp
|
|
87
88
|
|
88
89
|
class FunctionInvocation
|
89
90
|
extend Helper
|
91
|
+
attr_accessor :function_instruction, :argument_instructions
|
90
92
|
|
91
93
|
def self.build expression, bindings
|
92
94
|
compiled = Compiler.compile_each(expression, bindings)
|
@@ -110,8 +112,10 @@ module Nydp
|
|
110
112
|
end
|
111
113
|
|
112
114
|
def execute vm
|
113
|
-
vm.
|
114
|
-
vm.
|
115
|
+
vm.instructions.push function_instruction
|
116
|
+
vm.contexts .push vm.current_context
|
117
|
+
vm.instructions.push argument_instructions
|
118
|
+
vm.contexts .push vm.current_context
|
115
119
|
end
|
116
120
|
|
117
121
|
def inspect ; @source.inspect ; end
|
@@ -4,7 +4,7 @@ require 'nydp/closure'
|
|
4
4
|
|
5
5
|
module Nydp
|
6
6
|
class PopArg
|
7
|
-
def self.execute vm ; vm.
|
7
|
+
def self.execute vm ; vm.args.pop ; end
|
8
8
|
def self.to_s ; "" ; end
|
9
9
|
def self.inspect ; "#pop_arg" ; end
|
10
10
|
end
|
@@ -16,31 +16,36 @@ module Nydp
|
|
16
16
|
attr_accessor :arg_names, :body, :context_builder
|
17
17
|
|
18
18
|
def invoke_1 vm, parent_context
|
19
|
-
vm.
|
19
|
+
vm.instructions.push self.body
|
20
|
+
vm.contexts.push LexicalContext.new(parent_context)
|
20
21
|
end
|
21
22
|
|
22
23
|
def invoke_2 vm, parent_context, arg
|
23
24
|
lc = LexicalContext.new parent_context
|
24
25
|
set_args_1 lc, arg
|
25
|
-
vm.
|
26
|
+
vm.instructions.push self.body
|
27
|
+
vm.contexts.push lc
|
26
28
|
end
|
27
29
|
|
28
30
|
def invoke_3 vm, parent_context, arg_0, arg_1
|
29
31
|
lc = LexicalContext.new parent_context
|
30
32
|
set_args_2 lc, arg_0, arg_1
|
31
|
-
vm.
|
33
|
+
vm.instructions.push self.body
|
34
|
+
vm.contexts.push lc
|
32
35
|
end
|
33
36
|
|
34
37
|
def invoke_4 vm, parent_context, arg_0, arg_1, arg_2
|
35
38
|
lc = LexicalContext.new parent_context
|
36
39
|
set_args_3 lc, arg_0, arg_1, arg_2
|
37
|
-
vm.
|
40
|
+
vm.instructions.push self.body
|
41
|
+
vm.contexts.push lc
|
38
42
|
end
|
39
43
|
|
40
44
|
def invoke vm, parent_context, arg_values
|
41
45
|
lc = LexicalContext.new parent_context
|
42
46
|
set_args lc, arg_values
|
43
|
-
vm.
|
47
|
+
vm.instructions.push self.body
|
48
|
+
vm.contexts.push lc
|
44
49
|
end
|
45
50
|
|
46
51
|
def setup_context context, names, values
|
@@ -85,7 +90,7 @@ module Nydp
|
|
85
90
|
end
|
86
91
|
|
87
92
|
def execute vm
|
88
|
-
vm.push_arg Closure.new(self, vm.
|
93
|
+
vm.push_arg Closure.new(self, vm.current_context)
|
89
94
|
end
|
90
95
|
|
91
96
|
def nydp_type ; "fn" ; end
|
data/lib/nydp/pair.rb
CHANGED
@@ -8,10 +8,6 @@ class Nydp::Pair
|
|
8
8
|
@car, @cdr = car, cdr
|
9
9
|
end
|
10
10
|
|
11
|
-
def self.mk a, b
|
12
|
-
new a, b
|
13
|
-
end
|
14
|
-
|
15
11
|
def nydp_type ; :pair ; end
|
16
12
|
def caar ; car.car ; end
|
17
13
|
def cadr ; cdr.car ; end
|
@@ -35,7 +31,7 @@ class Nydp::Pair
|
|
35
31
|
if n >= list.size
|
36
32
|
last
|
37
33
|
else
|
38
|
-
|
34
|
+
new list[n], from_list(list, last, n+1)
|
39
35
|
end
|
40
36
|
end
|
41
37
|
|
@@ -76,7 +72,7 @@ class Nydp::Pair
|
|
76
72
|
"'#{cdr.to_s}"
|
77
73
|
end
|
78
74
|
elsif car.is_a?(Nydp::Symbol) && car.is?(:"brace-list")
|
79
|
-
if Nydp.NIL.is? cdr
|
75
|
+
if Nydp.NIL.is? cdr
|
80
76
|
"{}"
|
81
77
|
else
|
82
78
|
"{ #{cdr.to_s_rest} }"
|
data/lib/nydp/symbol.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
class Nydp::Symbol
|
2
2
|
EMPTY = :""
|
3
3
|
attr_accessor :name
|
4
|
+
attr_reader :hash
|
4
5
|
|
5
6
|
def initialize name
|
6
7
|
@name = name.to_sym
|
7
8
|
@inspection = name.to_s
|
8
9
|
@inspection = "|#{name}|" if untidy(@inspection)
|
10
|
+
@hash = name.hash
|
9
11
|
end
|
10
12
|
|
11
13
|
def untidy str
|
@@ -37,7 +39,6 @@ class Nydp::Symbol
|
|
37
39
|
def to_s ; name.to_s ; end
|
38
40
|
def to_sym ; name ; end
|
39
41
|
def to_ruby ; to_sym ; end
|
40
|
-
def hash ; name.hash ; end
|
41
42
|
def eql? other ; self == other ; end
|
42
43
|
def is? nm ; self.name == nm.to_sym ; end
|
43
44
|
def > other ; self.name > other.name ; end
|
data/lib/nydp/symbol_lookup.rb
CHANGED
data/lib/nydp/version.rb
CHANGED
data/lib/nydp/vm.rb
CHANGED
@@ -30,7 +30,7 @@ module Nydp
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
raise_unhandled_error
|
33
|
-
|
33
|
+
args.pop
|
34
34
|
end
|
35
35
|
|
36
36
|
def raise_unhandled_error
|
@@ -58,28 +58,21 @@ module Nydp
|
|
58
58
|
end
|
59
59
|
|
60
60
|
while protecti.length > 0
|
61
|
-
|
61
|
+
instructions.push protecti.pop
|
62
|
+
contexts.push protectc.pop
|
62
63
|
end
|
63
64
|
end
|
64
65
|
|
65
|
-
def peek_context ; current_context ; end
|
66
|
-
def pop_context ; contexts.pop ; end
|
67
66
|
def push_arg a ; args.push a ; end
|
68
67
|
def args! ; args.empty? ? (raise "illegal operation: no args") : args ; end
|
69
68
|
def peek_arg ; args!.last ; end
|
70
|
-
def pop_arg ; args!.pop ; end
|
71
|
-
|
72
|
-
def push_instructions ii, ctx
|
73
|
-
instructions.push ii
|
74
|
-
contexts.push ctx
|
75
|
-
end
|
76
69
|
|
77
70
|
def pop_args count, tail=Nydp.NIL
|
78
71
|
case count
|
79
72
|
when 0
|
80
73
|
tail
|
81
74
|
else
|
82
|
-
pop_args(count - 1, cons(
|
75
|
+
pop_args(count - 1, cons(args.pop, tail))
|
83
76
|
end
|
84
77
|
end
|
85
78
|
|
data/spec/date_spec.rb
CHANGED
@@ -18,7 +18,7 @@ describe Nydp::Date do
|
|
18
18
|
it "creates a new date" do
|
19
19
|
df = Nydp::Builtin::Date.new
|
20
20
|
df.invoke vm, pair_list([2015, 11, 18])
|
21
|
-
nd = vm.
|
21
|
+
nd = vm.args.pop
|
22
22
|
expect(nd).to be_a Nydp::Date
|
23
23
|
expect(nd.ruby_date).to eq Date.parse("2015-11-18")
|
24
24
|
end
|
@@ -40,7 +40,7 @@ describe Nydp::Date do
|
|
40
40
|
minus = Nydp::Builtin::Minus.new
|
41
41
|
|
42
42
|
minus.invoke vm, pair_list([d1, d0])
|
43
|
-
diff = vm.
|
43
|
+
diff = vm.args.pop
|
44
44
|
|
45
45
|
expect(d0).to be_a Nydp::Date
|
46
46
|
expect(diff).to eq 6
|
@@ -52,7 +52,7 @@ describe Nydp::Date do
|
|
52
52
|
|
53
53
|
f.invoke vm, pair_list([d1, d0])
|
54
54
|
|
55
|
-
expect(vm.
|
55
|
+
expect(vm.args.pop).to eq Nydp.T
|
56
56
|
end
|
57
57
|
|
58
58
|
it "compares with nil" do
|
@@ -60,7 +60,7 @@ describe Nydp::Date do
|
|
60
60
|
|
61
61
|
f.invoke vm, pair_list([d1, Nydp.NIL])
|
62
62
|
|
63
|
-
expect(vm.
|
63
|
+
expect(vm.args.pop).to eq Nydp.NIL
|
64
64
|
end
|
65
65
|
|
66
66
|
it "works with builtin greater-than when false" do
|
@@ -68,7 +68,7 @@ describe Nydp::Date do
|
|
68
68
|
|
69
69
|
f.invoke vm, pair_list([d0, d1])
|
70
70
|
|
71
|
-
expect(vm.
|
71
|
+
expect(vm.args.pop).to eq Nydp.NIL
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
@@ -78,7 +78,7 @@ describe Nydp::Date do
|
|
78
78
|
|
79
79
|
f.invoke vm, pair_list([d0, d1])
|
80
80
|
|
81
|
-
expect(vm.
|
81
|
+
expect(vm.args.pop).to eq Nydp.T
|
82
82
|
end
|
83
83
|
|
84
84
|
it "works with builtin less-than when false" do
|
@@ -86,7 +86,7 @@ describe Nydp::Date do
|
|
86
86
|
|
87
87
|
f.invoke vm, pair_list([d1, d0])
|
88
88
|
|
89
|
-
expect(vm.
|
89
|
+
expect(vm.args.pop).to eq Nydp.NIL
|
90
90
|
end
|
91
91
|
|
92
92
|
it "compares with nil" do
|
@@ -94,7 +94,7 @@ describe Nydp::Date do
|
|
94
94
|
|
95
95
|
f.invoke vm, pair_list([d1, Nydp.NIL])
|
96
96
|
|
97
|
-
expect(vm.
|
97
|
+
expect(vm.args.pop).to eq Nydp.NIL
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
@@ -102,7 +102,7 @@ describe Nydp::Date do
|
|
102
102
|
plus = Nydp::Builtin::Plus.new
|
103
103
|
|
104
104
|
plus.invoke vm, pair_list([d0, 5])
|
105
|
-
sum = vm.
|
105
|
+
sum = vm.args.pop
|
106
106
|
|
107
107
|
expect(d0) .to be_a Nydp::Date
|
108
108
|
expect(sum).to be_a Nydp::Date
|
data/spec/foreign_hash_spec.rb
CHANGED
@@ -17,7 +17,7 @@ describe Nydp::Hash do
|
|
17
17
|
expect(ahash[:keysym].class).to eq String
|
18
18
|
expect(ahash.keys). to eq [:keysym]
|
19
19
|
|
20
|
-
expect(vm.
|
20
|
+
expect(vm.args.pop).to eq v
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -29,7 +29,7 @@ describe Nydp::Hash do
|
|
29
29
|
|
30
30
|
Nydp::Builtin::HashGet.new(ns).invoke vm, pair_list(args)
|
31
31
|
|
32
|
-
expect(vm.
|
32
|
+
expect(vm.args.pop).to eq Nydp::StringAtom.new("avalue")
|
33
33
|
end
|
34
34
|
|
35
35
|
it "converts ruby nil to nydp value" do
|
@@ -38,7 +38,7 @@ describe Nydp::Hash do
|
|
38
38
|
|
39
39
|
Nydp::Builtin::HashGet.new(ns).invoke vm, pair_list(args)
|
40
40
|
|
41
|
-
expect(vm.
|
41
|
+
expect(vm.args.pop).to eq Nydp.NIL
|
42
42
|
end
|
43
43
|
|
44
44
|
it "converts ruby true to nydp value" do
|
@@ -48,7 +48,7 @@ describe Nydp::Hash do
|
|
48
48
|
|
49
49
|
Nydp::Builtin::HashGet.new(ns).invoke vm, pair_list(args)
|
50
50
|
|
51
|
-
expect(vm.
|
51
|
+
expect(vm.args.pop).to eq Nydp.T
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -60,7 +60,7 @@ describe Nydp::Hash do
|
|
60
60
|
|
61
61
|
Nydp::Builtin::HashKeyPresent.new(ns).invoke vm, pair_list(args)
|
62
62
|
|
63
|
-
expect(vm.
|
63
|
+
expect(vm.args.pop).to eq Nydp.T
|
64
64
|
end
|
65
65
|
|
66
66
|
it "returns nil when key is absent" do
|
@@ -69,7 +69,7 @@ describe Nydp::Hash do
|
|
69
69
|
|
70
70
|
Nydp::Builtin::HashKeyPresent.new(ns).invoke vm, pair_list(args)
|
71
71
|
|
72
|
-
expect(vm.
|
72
|
+
expect(vm.args.pop).to eq Nydp.NIL
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -81,7 +81,7 @@ describe Nydp::Hash do
|
|
81
81
|
|
82
82
|
Nydp::Builtin::HashKeys.new(ns).invoke vm, pair_list(args)
|
83
83
|
|
84
|
-
expect(vm.
|
84
|
+
expect(vm.args.pop).to eq pair_list [sym("k0"), sym("k1")]
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|
@@ -12,7 +12,7 @@ describe Nydp::Hash do
|
|
12
12
|
args = [ ahash, k ]
|
13
13
|
|
14
14
|
Nydp::Builtin::HashGet.new(ns).invoke vm, pair_list(args)
|
15
|
-
expect(vm.
|
15
|
+
expect(vm.args.pop).to eq 123
|
16
16
|
end
|
17
17
|
|
18
18
|
it "converts ruby value to nydp value" do
|
@@ -20,7 +20,7 @@ describe Nydp::Hash do
|
|
20
20
|
args = [ ahash, k ]
|
21
21
|
|
22
22
|
Nydp::Builtin::HashGet.new(ns).invoke vm, pair_list(args)
|
23
|
-
expect(vm.
|
23
|
+
expect(vm.args.pop).to eq Nydp::StringAtom.new("hello there")
|
24
24
|
end
|
25
25
|
|
26
26
|
it "converts string keys to method names" do
|
@@ -28,7 +28,7 @@ describe Nydp::Hash do
|
|
28
28
|
args = [ ahash, k ]
|
29
29
|
|
30
30
|
Nydp::Builtin::HashGet.new(ns).invoke vm, pair_list(args)
|
31
|
-
expect(vm.
|
31
|
+
expect(vm.args.pop).to eq Nydp::StringAtom.new("hello there")
|
32
32
|
end
|
33
33
|
|
34
34
|
it "returns nil for unavailable methods" do
|
@@ -36,7 +36,7 @@ describe Nydp::Hash do
|
|
36
36
|
args = [ ahash, k ]
|
37
37
|
|
38
38
|
Nydp::Builtin::HashGet.new(ns).invoke vm, pair_list(args)
|
39
|
-
expect(vm.
|
39
|
+
expect(vm.args.pop).to eq Nydp.NIL
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
data/spec/hash_spec.rb
CHANGED
@@ -63,7 +63,7 @@ describe Nydp::Hash do
|
|
63
63
|
describe "new hash" do
|
64
64
|
it "returns a new Nydp hash" do
|
65
65
|
Nydp::Builtin::Hash.new.invoke vm, Nydp.NIL
|
66
|
-
h = vm.
|
66
|
+
h = vm.args.pop
|
67
67
|
expect(h).to be_a Nydp::Hash
|
68
68
|
end
|
69
69
|
end
|
@@ -78,7 +78,7 @@ describe Nydp::Hash do
|
|
78
78
|
|
79
79
|
expect(h.keys). to eq [k]
|
80
80
|
expect(h[k]). to eq v
|
81
|
-
expect(vm.
|
81
|
+
expect(vm.args.pop).to eq v
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -91,7 +91,7 @@ describe Nydp::Hash do
|
|
91
91
|
|
92
92
|
args = Nydp::Pair.from_list([h, k])
|
93
93
|
Nydp::Builtin::HashGet.new(ns).invoke vm, args
|
94
|
-
expect(vm.
|
94
|
+
expect(vm.args.pop).to eq v
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
@@ -104,7 +104,7 @@ describe Nydp::Hash do
|
|
104
104
|
|
105
105
|
Nydp::Builtin::HashKeyPresent.new(ns).invoke vm, pair_list([h, k])
|
106
106
|
|
107
|
-
expect(vm.
|
107
|
+
expect(vm.args.pop).to eq Nydp.T
|
108
108
|
end
|
109
109
|
|
110
110
|
it "returns nil when key is absent" do
|
@@ -113,7 +113,7 @@ describe Nydp::Hash do
|
|
113
113
|
|
114
114
|
Nydp::Builtin::HashKeyPresent.new(ns).invoke vm, pair_list([h, k])
|
115
115
|
|
116
|
-
expect(vm.
|
116
|
+
expect(vm.args.pop).to eq Nydp.NIL
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
@@ -125,7 +125,7 @@ describe Nydp::Hash do
|
|
125
125
|
|
126
126
|
args = Nydp::Pair.from_list([h])
|
127
127
|
Nydp::Builtin::HashKeys.new(ns).invoke vm, args
|
128
|
-
expect(vm.
|
128
|
+
expect(vm.args.pop).to eq pair_list [sym("k0"), sym("k1")]
|
129
129
|
end
|
130
130
|
end
|
131
131
|
end
|
@@ -141,7 +141,7 @@ describe Nydp::Hash do
|
|
141
141
|
Nydp::Builtin::HashSet.new.invoke vm, args
|
142
142
|
|
143
143
|
expect(ahash). to eq Nydp.NIL
|
144
|
-
expect(vm.
|
144
|
+
expect(vm.args.pop).to eq v
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
@@ -152,7 +152,7 @@ describe Nydp::Hash do
|
|
152
152
|
|
153
153
|
Nydp::Builtin::HashGet.new(ns).invoke vm, pair_list(args)
|
154
154
|
|
155
|
-
expect(vm.
|
155
|
+
expect(vm.args.pop).to eq Nydp.NIL
|
156
156
|
end
|
157
157
|
end
|
158
158
|
end
|
data/spec/pair_spec.rb
CHANGED
data/spec/string_atom_spec.rb
CHANGED
@@ -32,7 +32,7 @@ describe Nydp::StringAtom do
|
|
32
32
|
|
33
33
|
f.invoke vm, pair_list([foo, bar])
|
34
34
|
|
35
|
-
expect(vm.
|
35
|
+
expect(vm.args.pop).to eq Nydp.T
|
36
36
|
end
|
37
37
|
|
38
38
|
it "works with builtin greater-than when false" do
|
@@ -40,7 +40,7 @@ describe Nydp::StringAtom do
|
|
40
40
|
|
41
41
|
f.invoke vm, pair_list([bar, foo])
|
42
42
|
|
43
|
-
expect(vm.
|
43
|
+
expect(vm.args.pop).to eq Nydp.NIL
|
44
44
|
end
|
45
45
|
|
46
46
|
it "works with builtin less-than when true" do
|
@@ -48,7 +48,7 @@ describe Nydp::StringAtom do
|
|
48
48
|
|
49
49
|
f.invoke vm, pair_list([bar, foo])
|
50
50
|
|
51
|
-
expect(vm.
|
51
|
+
expect(vm.args.pop).to eq Nydp.T
|
52
52
|
end
|
53
53
|
|
54
54
|
it "works with builtin less-than when false" do
|
@@ -56,6 +56,6 @@ describe Nydp::StringAtom do
|
|
56
56
|
|
57
57
|
f.invoke vm, pair_list([foo, bar])
|
58
58
|
|
59
|
-
expect(vm.
|
59
|
+
expect(vm.args.pop).to eq Nydp.NIL
|
60
60
|
end
|
61
61
|
end
|
data/spec/symbol_spec.rb
CHANGED
@@ -47,7 +47,7 @@ describe Nydp::Symbol do
|
|
47
47
|
|
48
48
|
f.invoke vm, pair_list([foo, bar])
|
49
49
|
|
50
|
-
expect(vm.
|
50
|
+
expect(vm.args.pop).to eq Nydp.T
|
51
51
|
end
|
52
52
|
|
53
53
|
it "works with builtin greater-than when false" do
|
@@ -55,7 +55,7 @@ describe Nydp::Symbol do
|
|
55
55
|
|
56
56
|
f.invoke vm, pair_list([bar, foo])
|
57
57
|
|
58
|
-
expect(vm.
|
58
|
+
expect(vm.args.pop).to eq Nydp.NIL
|
59
59
|
end
|
60
60
|
|
61
61
|
it "works with builtin less-than when true" do
|
@@ -63,7 +63,7 @@ describe Nydp::Symbol do
|
|
63
63
|
|
64
64
|
f.invoke vm, pair_list([bar, foo])
|
65
65
|
|
66
|
-
expect(vm.
|
66
|
+
expect(vm.args.pop).to eq Nydp.T
|
67
67
|
end
|
68
68
|
|
69
69
|
it "works with builtin less-than when false" do
|
@@ -71,7 +71,7 @@ describe Nydp::Symbol do
|
|
71
71
|
|
72
72
|
f.invoke vm, pair_list([foo, bar])
|
73
73
|
|
74
|
-
expect(vm.
|
74
|
+
expect(vm.args.pop).to eq Nydp.NIL
|
75
75
|
end
|
76
76
|
|
77
77
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nydp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Conan Dalton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|