rVM 0.0.11 → 0.0.12

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.
@@ -1,6 +1,6 @@
1
- require File.dirname(__FILE__) +'/../../lib/rvm'
2
- require File.dirname(__FILE__) +'/../../lib/rvm/languages'
3
- require File.dirname(__FILE__) +'/../../lib/rvm/languages/ecma'
1
+ require File.dirname(__FILE__) +'/../../../lib/rvm'
2
+ require File.dirname(__FILE__) +'/../../../lib/rvm/languages'
3
+ require File.dirname(__FILE__) +'/../../../lib/rvm/languages/ecma'
4
4
 
5
5
  describe RVM::Languages::ECMA do
6
6
  def exec code
@@ -22,36 +22,34 @@ describe RVM::Languages::ECMA do
22
22
  end
23
23
 
24
24
  it "should handle newline replacements" do
25
- res = exec <<-EOC
26
- "\n"
27
- EOC
25
+ res = exec '"\n"'
28
26
  res.should == "\n"
29
27
  end
30
28
 
31
29
  it "should handle newline replacements" do
32
30
  res = exec <<-EOC
33
- "\t"
31
+ "\\t"
34
32
  EOC
35
33
  res.should == "\t"
36
34
  end
37
35
  it "should handle newline replacements" do
38
36
  res = exec <<-EOC
39
- "\n"
37
+ "\\n"
40
38
  EOC
41
39
  res.should == "\n"
42
40
  end
43
41
 
44
42
  it "should handle double escapes" do
45
43
  res = exec <<-EOC
46
- "\\t"
44
+ "\\\\t"
47
45
  EOC
48
46
  res.should == "\\t"
49
47
  end
50
48
 
51
49
  it "should handle double escapes followed by single escapes" do
52
- res = exec <<-EOC
53
- "\\\t"
54
- EOC
50
+ res = exec <<-EOF
51
+ "\\\\\\t"
52
+ EOF
55
53
  res.should == "\\\t"
56
54
  end
57
55
  end
@@ -63,11 +61,65 @@ describe RVM::Languages::ECMA do
63
61
  res.should == 42
64
62
  end
65
63
 
66
- it "should handle array literals" do
67
- res = exec <<-EOC
68
- [42, "Kekse!"]
69
- EOC
70
- res.should == [42, "Kekse!"]
64
+ describe "array" do
65
+ it "should handle array literals with no elements" do
66
+ res = exec <<-EOC
67
+ []
68
+ EOC
69
+ res.should == []
70
+ end
71
+
72
+ it "should handle array literals with one element" do
73
+ res = exec <<-EOC
74
+ ["Kekse!"]
75
+ EOC
76
+ res.should == ["Kekse!"]
77
+ end
78
+
79
+ it "should handle array literals with arrays in it" do
80
+ res = exec <<-EOC
81
+ [["Kekse!",2],1]
82
+ EOC
83
+ res.should == [["Kekse!",2],1]
84
+ end
85
+
86
+ it "should handle array literals with multiple elements" do
87
+ res = exec <<-EOC
88
+ [42, "Kekse!"]
89
+ EOC
90
+ res.should == [42, "Kekse!"]
91
+ end
92
+ end
93
+
94
+ describe "associative array" do
95
+ it "should handle an empty associative array literals" do
96
+ res = exec <<-EOC
97
+ {}
98
+ EOC
99
+ res.should == {}
100
+ end
101
+
102
+ it "should handle an associative array literals with one element" do
103
+ res = exec <<-EOC
104
+ {1:2}
105
+ EOC
106
+ res.should == {1 => 2}
107
+ end
108
+
109
+ it "should handle an associative array literals with multiple element" do
110
+ res = exec <<-EOC
111
+ {1:2, 'test' : 'toast'}
112
+ EOC
113
+ res.should == {1 => 2, 'test' => 'toast'}
114
+ end
115
+
116
+ it "should handle hashes within hashes" do
117
+ res = exec <<-EOC
118
+ {1:{1:2}, 'test' : 'toast'}
119
+ EOC
120
+ res.should == {1 => {1 => 2}, 'test' => 'toast'}
121
+
122
+ end
71
123
  end
72
124
 
73
125
  it "should handle true literals" do
@@ -86,7 +138,6 @@ describe RVM::Languages::ECMA do
86
138
  end
87
139
 
88
140
  describe "array" do
89
-
90
141
  it "should allow accessing elements" do
91
142
  @env['a'] = RVM::Classes::List.new([1,2,3])
92
143
  res = exec <<-EOC
@@ -102,7 +153,6 @@ describe RVM::Languages::ECMA do
102
153
  EOC
103
154
  res.should == 3
104
155
  end
105
-
106
156
  end
107
157
 
108
158
  describe "variables" do
@@ -0,0 +1,32 @@
1
+ require File.dirname(__FILE__) +'/../../../lib/rvm'
2
+ require File.dirname(__FILE__) +'/../../../lib/rvm/languages'
3
+ require File.dirname(__FILE__) +'/../../../lib/rvm/languages/ecma'
4
+
5
+ describe RVM::Languages::ECMA do
6
+ def exec code
7
+ @compiler.compile(code).execute(@env)
8
+ end
9
+
10
+ before(:each) do
11
+ @env = RVM::Interpreter.env
12
+ @compiler = RVM::Languages::ECMA.new
13
+ end
14
+
15
+ it "should compile the first json example" do
16
+ lambda {
17
+ exec File.new(File.dirname(__FILE__) + '/pass1.json').read
18
+ }.should_not raise_error
19
+ end
20
+
21
+ it "should compile the second json example" do
22
+ lambda {
23
+ exec File.new(File.dirname(__FILE__) + '/pass2.json').read
24
+ }.should_not raise_error
25
+ end
26
+
27
+ it "should compile the third json example" do
28
+ lambda {
29
+ exec File.new(File.dirname(__FILE__) + '/pass3.json').read
30
+ }.should_not raise_error
31
+ end
32
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rVM
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Heinz N. Gies
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-07-23 00:00:00 +02:00
12
+ date: 2008-07-24 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -167,7 +167,8 @@ test_files:
167
167
  - spec/functions/string/ljust_spec.rb
168
168
  - spec/functions/string/regmatch_spec.rb
169
169
  - spec/functions/string/rjust_spec.rb
170
- - spec/languages/ecma_spec.rb
170
+ - spec/languages/ecma/ecma_spec.rb
171
+ - spec/languages/ecma/json_spec.rb
171
172
  - spec/languages/math/compiler_spec.rb
172
173
  - spec/languages/math/tokenizer_spec.rb
173
174
  - spec/languages/math/tree_spec.rb