relisp 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,275 @@
1
+ # Code Generated by ZenTest v. 3.11.1
2
+
3
+ require 'test/unit' unless defined? $ZENTEST and $ZENTEST
4
+
5
+ $:.unshift File.dirname(__FILE__) + "/../lib"
6
+ require 'relisp'
7
+
8
+ # when this elisp line:
9
+ ### (eval (read (trim-trailing-whitespace relisp-ruby-return)))))
10
+ # was this (i.e., without the eval:
11
+ ### (read (trim-trailing-whitespace relisp-ruby-return))))
12
+ # this would return :hash-table':
13
+ ### @emacs.elisp_eval( "(type-of #{hash.to_elisp})" )
14
+ # while this would return :cons':
15
+ ### @emacs.elisp_eval( '(type-of (ruby-eval "hash"))' )
16
+ # So the second way needs to be included in testing.
17
+
18
+
19
+ class TestArray < Test::Unit::TestCase
20
+ def setup
21
+ @emacs = Relisp::ElispSlave.new
22
+ end
23
+
24
+ def test_class_from_elisp
25
+ assert "if from_elisp works for Vector and Cons, then this works"
26
+ end
27
+
28
+ def test_class_default_elisp_type_equals
29
+ assert_raise ArgumentError do
30
+ Array.default_elisp_type = Fixnum
31
+ end
32
+ Array.default_elisp_type = Relisp::Vector
33
+ assert_equal Relisp::Vector, Array.default_elisp_type
34
+ Array.default_elisp_type = Relisp::Cons
35
+ assert_equal Relisp::Cons, Array.default_elisp_type
36
+ end
37
+
38
+ def test_to_elisp
39
+ Array.default_elisp_type = Relisp::Cons
40
+ assert_equal :cons, @emacs.elisp_eval( "(type-of #{[1, 2, 3].to_elisp})" )
41
+ Array.default_elisp_type = Relisp::Vector
42
+ assert_equal :vector, @emacs.elisp_eval( "(type-of #{[1, 2, 3].to_elisp})" )
43
+ end
44
+
45
+ def test_elisp_type
46
+ array = [1, 2, 3]
47
+ assert_equal Array.default_elisp_type, array.elisp_type
48
+ assert_raise ArgumentError do
49
+ array.elisp_type = Fixnum
50
+ end
51
+ array.elisp_type = Relisp::Vector
52
+ assert_equal Relisp::Vector, array.elisp_type
53
+ end
54
+
55
+ def test_elisp_type_equals
56
+ Array.default_elisp_type = Relisp::Cons
57
+ array = [1, 2, 3]
58
+ assert_equal :cons, @emacs.elisp_eval( "(type-of #{array.to_elisp})" )
59
+ array.elisp_type = Relisp::Vector
60
+ assert_equal :vector, @emacs.elisp_eval( "(type-of #{array.to_elisp})" )
61
+ end
62
+ end
63
+
64
+ class TestClass < Test::Unit::TestCase
65
+ def test_to_elisp
66
+ @emacs = Relisp::ElispSlave.new
67
+ assert_equal :Array, @emacs.elisp_eval('(ruby-eval "[1, 2].class")')
68
+ end
69
+ end
70
+
71
+ class TestFalseClass < Test::Unit::TestCase
72
+ def setup
73
+ @emacs = Relisp::ElispSlave.new
74
+ end
75
+
76
+ def test_to_elisp
77
+ assert @emacs.elisp_eval("(equal (equal 1 2) #{false.to_elisp})")
78
+ assert @emacs.elisp_eval("(equal (equal 1 2) (ruby-eval \"false\"))")
79
+ end
80
+ end
81
+
82
+ class TestNilClass < Test::Unit::TestCase
83
+ def setup
84
+ @emacs = Relisp::ElispSlave.new
85
+ end
86
+
87
+ def test_class_from_elisp
88
+ assert_nil @emacs.elisp_eval("(equal 1 2)")
89
+ end
90
+
91
+ def test_to_elisp
92
+ assert @emacs.elisp_eval("(null #{nil.to_elisp})")
93
+ assert @emacs.elisp_eval("(null (ruby-eval \"nil\"))")
94
+ end
95
+ end
96
+
97
+ class TestObject < Test::Unit::TestCase
98
+ def setup
99
+ @emacs = Relisp::ElispSlave.new
100
+ end
101
+
102
+ def test_class_from_elisp
103
+ assert_nothing_raised { IO.from_elisp("blah", 2345) }
104
+ end
105
+
106
+ def test_to_elisp
107
+ assert_nothing_raised { binding.to_elisp }
108
+ end
109
+ end
110
+
111
+ class TestTrueClass < Test::Unit::TestCase
112
+ def setup
113
+ @emacs = Relisp::ElispSlave.new
114
+ end
115
+
116
+ def test_to_elisp
117
+ assert @emacs.elisp_eval( '(ruby-eval "true")' )
118
+ end
119
+ end
120
+
121
+ module TestRelisp
122
+ class TestCons < Test::Unit::TestCase
123
+ def setup
124
+ @emacs = Relisp::ElispSlave.new
125
+ end
126
+
127
+ def test_class_from_elisp
128
+ Array.default_elisp_type = Relisp::Cons
129
+ result = @emacs.elisp_eval( "'(1 \"string\" 3 [4 5] )" )
130
+ assert result.kind_of?(Array)
131
+ assert_equal Relisp::Cons, result.class
132
+ assert_equal "string", result[1]
133
+ assert_equal [4, 5], result[3]
134
+ end
135
+
136
+ def test_to_elisp
137
+ list = [1,2,'a',[4,5]]
138
+ list.elisp_type = Relisp::Cons
139
+ assert @emacs.elisp_eval( "(equal (list 1 2 \"a\" (list 4 5)) #{list.to_elisp})" )
140
+ assert @emacs.elisp_eval( "(equal (list 1 2 \"a\" (list 4 5)) (ruby-eval \"[1, 2, 'a', [4, 5]]\"))" )
141
+ assert_equal 1, @emacs.elisp_eval( "(car #{list.to_elisp})" )
142
+ end
143
+ end
144
+
145
+ class TestFloat < Test::Unit::TestCase
146
+ def setup
147
+ @emacs = Relisp::ElispSlave.new
148
+ end
149
+
150
+ def test_class_from_elisp
151
+ assert_equal 2.5, @emacs.elisp_eval( "(/ 5.0 2)" )
152
+ end
153
+
154
+ def test_to_elisp
155
+ assert @emacs.elisp_eval( "(equal -7.5 (* 3 #{-2.5.to_elisp}))" )
156
+ assert @emacs.elisp_eval( '(equal -7.5 (* 3 (ruby-eval "-2.5")))' )
157
+ end
158
+ end
159
+
160
+ class TestHashTable < Test::Unit::TestCase
161
+ def setup
162
+ @emacs = Relisp::ElispSlave.new
163
+ @emacs.elisp_execute( '(setq ht (make-hash-table))' )
164
+ @emacs.elisp_execute( '(puthash "first" "john" ht)' )
165
+ @emacs.elisp_execute( '(puthash \'last "doe" ht)' )
166
+ @emacs.elisp_execute( '(setq subht (make-hash-table))' )
167
+ @emacs.elisp_execute( '(puthash "first" "john" subht)' )
168
+ @emacs.elisp_execute( '(puthash \'last "doe" subht)' )
169
+ @emacs.elisp_execute( '(puthash \'sub subht ht)' )
170
+ end
171
+
172
+ def test_class_from_elisp
173
+ hash = @emacs.elisp_eval( 'ht' )
174
+ ruby_hash = Hash.new
175
+ ruby_hash["first"] = 'john'
176
+ ruby_hash[:last] = 'doe'
177
+ copy = ruby_hash.dup
178
+ ruby_hash[:sub] = copy
179
+ assert_equal ruby_hash, hash
180
+ end
181
+
182
+ def test_to_elisp
183
+ hash = @emacs.elisp_eval( 'ht' )
184
+ ruby_hash = Hash.new
185
+ ruby_hash["first"] = 'john'
186
+ ruby_hash[:last] = 'doe'
187
+ copy = ruby_hash.dup
188
+ ruby_hash[:sub] = copy
189
+ assert_equal hash, @emacs.elisp_eval( hash.to_elisp )
190
+ @emacs.provide(:hash, binding)
191
+ @emacs.elisp_eval( '(type-of (ruby-eval "hash"))' )
192
+ end
193
+ end
194
+
195
+ class TestInteger < Test::Unit::TestCase
196
+ def setup
197
+ @emacs = Relisp::ElispSlave.new
198
+ end
199
+
200
+ def test_class_from_elisp
201
+ assert_equal 3, @emacs.elisp_eval( "(+ 1 2)" )
202
+ end
203
+
204
+ def test_to_elisp
205
+ assert @emacs.elisp_eval( "(equal -2 (+ 1 #{-3.to_elisp}))" )
206
+ assert @emacs.elisp_eval( '(equal -2 (+ 1 (ruby-eval "-3")))' )
207
+ end
208
+ end
209
+
210
+ class TestString < Test::Unit::TestCase
211
+ def setup
212
+ @emacs = Relisp::ElispSlave.new
213
+ end
214
+
215
+ def test_class_from_elisp
216
+ assert_equal "String test", @emacs.elisp_eval( '(concat "String " "test")')
217
+ end
218
+
219
+ def test_to_elisp
220
+ str = "a string\nwith two lines"
221
+ assert @emacs.elisp_eval( "(equal \"a string\\nwith two lines\" #{str.to_elisp} )" )
222
+ @emacs.provide(:str, binding)
223
+ assert @emacs.elisp_eval( "(equal \"a string\\nwith two lines\" (ruby-eval \"str\") )" )
224
+ end
225
+ end
226
+
227
+ class TestSymbol < Test::Unit::TestCase
228
+ def setup
229
+ @emacs = Relisp::ElispSlave.new
230
+ end
231
+
232
+ def test_class_from_elisp
233
+ assert_equal :+, @emacs.elisp_eval( "'+" )
234
+ assert_nil @emacs.elisp_eval( 'nil' )
235
+ assert_equal true, @emacs.elisp_eval( '(equal 1 1)' )
236
+ end
237
+
238
+ def test_to_elisp
239
+ assert_equal 3, @emacs.elisp_eval( "(funcall #{:+.to_elisp} 1 2)" )
240
+ assert_equal 3, @emacs.elisp_eval( "(#{:+} 1 2)" )
241
+ assert @emacs.elisp_eval( "(equal '+ #{:+.to_elisp})" )
242
+ assert @emacs.elisp_eval( "(equal '+ (ruby-eval \":+\"))" )
243
+ assert @emacs.elisp_eval( "(null #{nil.to_elisp})" )
244
+ assert @emacs.elisp_eval( "(null (ruby-eval \"nil\"))" )
245
+ assert @emacs.elisp_eval( "(equal #{true.to_elisp} (equal 1 1))" )
246
+ assert @emacs.elisp_eval( "(equal (ruby-eval \"true\") (equal 1 1))" )
247
+ end
248
+ end
249
+
250
+ class TestVector < Test::Unit::TestCase
251
+ def setup
252
+ @emacs = Relisp::ElispSlave.new
253
+ end
254
+
255
+ def test_class_from_elisp
256
+ result = @emacs.elisp_eval( "[1 \"string\" 3 [\"sub\" \"array\" 5] ]" )
257
+ assert result.kind_of?(Array)
258
+ assert_equal Relisp::Vector, result.class
259
+ assert_equal "string", result[1]
260
+ assert_equal ["sub", "array", 5], result[3]
261
+ end
262
+
263
+ def test_to_elisp
264
+ vect = [1,2,'a',[4,5]]
265
+ vect.elisp_type=Relisp::Vector
266
+ assert @emacs.elisp_eval( "(equal [1 2 \"a\" (list 4 5)] #{vect.to_elisp})" )
267
+ Array.default_elisp_type=Relisp::Vector
268
+ assert @emacs.elisp_eval( "(equal [1 2 \"a\" [4 5]] #{vect.to_elisp})" )
269
+ vect = (1..100).to_a
270
+ assert_equal vect, @emacs.elisp_eval( vect.to_elisp )
271
+ assert_equal vect, @emacs.elisp_eval( "(ruby-eval \"(1..100).to_a \")" )
272
+ end
273
+ end
274
+ end
275
+
@@ -0,0 +1,84 @@
1
+ # Code Generated by ZenTest v. 3.11.1
2
+
3
+ require 'test/unit' unless defined? $ZENTEST and $ZENTEST
4
+
5
+ $:.unshift File.dirname(__FILE__) + "/../lib"
6
+ require 'relisp'
7
+
8
+ module TestRelisp
9
+ class TestElispSlave < Test::Unit::TestCase
10
+ def setup
11
+ @emacs = Relisp::ElispSlave.new
12
+ end
13
+
14
+ def test_debugging
15
+ @emacs.debugging
16
+ assert @emacs.debug
17
+ @emacs.debugging
18
+ assert ! @emacs.debug
19
+ end
20
+
21
+ def test_do
22
+ assert_equal 3, @emacs.do("(+ 1 2)")
23
+ end
24
+ end
25
+ end
26
+
27
+ # module TestRelisp
28
+ # class TestRubySlave < Test::Unit::TestCase
29
+ # end
30
+ # end
31
+
32
+ module TestRelisp
33
+ class TestSlave < Test::Unit::TestCase
34
+ def setup
35
+ @emacs = Relisp::ElispSlave.new
36
+ end
37
+
38
+ def test_elisp_eval
39
+ # this is really tested in plenty of other places
40
+ assert_equal 3, @emacs.elisp_eval("(+ 1 2)")
41
+ end
42
+
43
+ def test_elisp_execute
44
+ @emacs.elisp_execute("(setq blah 17)")
45
+ assert_equal 17, @emacs.elisp_eval(:blah)
46
+ assert_raise Relisp::ElispError do
47
+ puts @emacs.elisp_execute("(relisp-nonsense-function 2)")
48
+ end
49
+
50
+ end
51
+
52
+ def test_get_permanent_variable
53
+ @emacs.elisp_eval("(setq foo 3)")
54
+ new_foo = @emacs.get_permanent_variable :foo
55
+ assert_equal @emacs.elisp_eval(new_foo), 3
56
+ end
57
+
58
+ def test_new_elisp_variable
59
+ vars = Array.new
60
+ size = 1000
61
+ size.times do
62
+ vars << @emacs.new_elisp_variable
63
+ end
64
+ assert_equal size, vars.uniq.size
65
+ end
66
+
67
+ def test_provide
68
+ test_array = [1, 2, 4]
69
+ @emacs.provide(:test_array, binding)
70
+ assert_equal test_array, @emacs.test_array
71
+ test_array.pop
72
+ assert_equal test_array, @emacs.test_array
73
+ end
74
+
75
+ def test_method_missing
76
+ assert_equal 6, @emacs.+(1, 2, 3)
77
+ assert_raise NameError do
78
+ @emacs.utter_nonsense
79
+ end
80
+ end
81
+ end
82
+ end
83
+
84
+
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: relisp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ platform: ruby
6
+ authors:
7
+ - Don
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-01-26 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: bones
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.2.0
24
+ version:
25
+ description: Call ruby from emacs and call elisp from ruby. If you never did you should. These things are fun and fun is good.
26
+ email: don@ohspite.net
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - README
33
+ files:
34
+ - CHANGELOG
35
+ - COPYING
36
+ - Manifest
37
+ - README
38
+ - Rakefile
39
+ - examples/elisp_master/elisp_master.el
40
+ - examples/elisp_master/ruby_slave
41
+ - examples/ruby_master/ruby_master_example
42
+ - lib/relisp.rb
43
+ - lib/relisp/editing_types.rb
44
+ - lib/relisp/programming_types.rb
45
+ - lib/relisp/slaves.rb
46
+ - setup.rb
47
+ - src/relisp.el
48
+ - src/relisp.elc
49
+ - tasks/ann.rake
50
+ - tasks/bones.rake
51
+ - tasks/gem.rake
52
+ - tasks/git.rake
53
+ - tasks/manifest.rake
54
+ - tasks/notes.rake
55
+ - tasks/post_load.rake
56
+ - tasks/rdoc.rake
57
+ - tasks/rubyforge.rake
58
+ - tasks/setup.rb
59
+ - tasks/spec.rake
60
+ - tasks/svn.rake
61
+ - tasks/test.rake
62
+ - test/test_editing_types.rb
63
+ - test/test_programming_types.rb
64
+ - test/test_slaves.rb
65
+ has_rdoc: true
66
+ homepage: relisp.rubyforge.org
67
+ post_install_message: |
68
+ ---------------------------
69
+ Wait! You're not finished!
70
+
71
+ The gem is installed, and you can now call elisp from ruby. But if
72
+ you want to call ruby from emacs (and you do, right?) you need to go
73
+ into the 'src' directory of this gem and copy 'relisp.el' and/or
74
+ 'relisp.elc' to your elisp folder (probably '~/.elisp'). Then you
75
+ might want to add the line "(require 'relisp)" to your emacs
76
+ initialization file (probably '~/.emacs').
77
+
78
+ If you don't know where to find the files for this gem, run the
79
+ command "gem env gemdir". Or you can download the tarball for this
80
+ gem and get the files there.
81
+ ---------------------------
82
+
83
+ rdoc_options:
84
+ - --main
85
+ - README
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: "0"
93
+ version:
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: "0"
99
+ version:
100
+ requirements: []
101
+
102
+ rubyforge_project: relisp
103
+ rubygems_version: 1.3.1
104
+ signing_key:
105
+ specification_version: 2
106
+ summary: Call ruby from emacs and call elisp from ruby. If you never did you should. These things are fun and fun is good.
107
+ test_files:
108
+ - test/test_editing_types.rb
109
+ - test/test_programming_types.rb
110
+ - test/test_slaves.rb