partialruby 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +1 -0
- data/CHANGELOG +3 -0
- data/LICENSE +674 -0
- data/README +89 -0
- data/Rakefile +47 -0
- data/TODO +3 -0
- data/lib/partialruby.rb +468 -0
- data/spec/block_spec.rb +83 -0
- data/spec/call_spec.rb +26 -0
- data/spec/class_spec.rb +34 -0
- data/spec/const_spec.rb +33 -0
- data/spec/def_spec.rb +35 -0
- data/spec/eval_spec.rb +85 -0
- data/spec/exception_spec.rb +53 -0
- data/spec/flow_control_spec.rb +38 -0
- data/spec/gvar_spec.rb +18 -0
- data/spec/ivar_spec.rb +18 -0
- data/spec/literal_spec.rb +24 -0
- data/spec/operator_spec.rb +39 -0
- data/spec/xstr_spec.rb +14 -0
- metadata +102 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
require "partialruby"
|
2
|
+
|
3
|
+
include PartialRuby
|
4
|
+
|
5
|
+
describe Context, "PartialRuby context" do
|
6
|
+
|
7
|
+
def self.assert_ruby_expr(expr, expected = nil)
|
8
|
+
|
9
|
+
expected ||= eval(expr)
|
10
|
+
|
11
|
+
it "should return #{expected} on expresion #{expr}" do
|
12
|
+
PartialRuby.eval(expr,binding).should be == expected
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.test_operators(*ops)
|
17
|
+
ops.each do |op|
|
18
|
+
assert_ruby_expr "2.0#{op}3.0"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
test_operators "+", "-", "/", "*", "**"
|
23
|
+
|
24
|
+
assert_ruby_expr "[1][0]"
|
25
|
+
|
26
|
+
values = ["true", "false"]
|
27
|
+
ops = ["and", "or", "&&", "||", "=="]
|
28
|
+
|
29
|
+
values.each do |value1|
|
30
|
+
assert_ruby_expr "not #{value1}"
|
31
|
+
assert_ruby_expr "!#{value1}"
|
32
|
+
values.each do |value2|
|
33
|
+
ops.each do |op|
|
34
|
+
assert_ruby_expr "#{value1} #{op} #{value2}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
data/spec/xstr_spec.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "partialruby"
|
2
|
+
|
3
|
+
include PartialRuby
|
4
|
+
|
5
|
+
describe Context, "PartialRuby context" do
|
6
|
+
it "should call external commands with xstr" do
|
7
|
+
PartialRuby.eval("`echo hello world`", binding).should be == "hello world\n"
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should call external commands with dxstr" do
|
11
|
+
PartialRuby.eval("text = 'hello world'; `echo \#{text}`", binding).should be == "hello world\n"
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: partialruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Dario Seminara
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-04-03 00:00:00 -03:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: ruby_parser
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 0
|
33
|
+
- 6
|
34
|
+
version: 2.0.6
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
description:
|
38
|
+
email: robertodarioseminara@gmail.com
|
39
|
+
executables: []
|
40
|
+
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files:
|
44
|
+
- README
|
45
|
+
files:
|
46
|
+
- lib/partialruby.rb
|
47
|
+
- spec/flow_control_spec.rb
|
48
|
+
- spec/gvar_spec.rb
|
49
|
+
- spec/def_spec.rb
|
50
|
+
- spec/exception_spec.rb
|
51
|
+
- spec/call_spec.rb
|
52
|
+
- spec/const_spec.rb
|
53
|
+
- spec/ivar_spec.rb
|
54
|
+
- spec/block_spec.rb
|
55
|
+
- spec/eval_spec.rb
|
56
|
+
- spec/literal_spec.rb
|
57
|
+
- spec/class_spec.rb
|
58
|
+
- spec/operator_spec.rb
|
59
|
+
- spec/xstr_spec.rb
|
60
|
+
- LICENSE
|
61
|
+
- AUTHORS
|
62
|
+
- CHANGELOG
|
63
|
+
- README
|
64
|
+
- Rakefile
|
65
|
+
- TODO
|
66
|
+
has_rdoc: true
|
67
|
+
homepage: http://github.com/tario/partialruby
|
68
|
+
licenses: []
|
69
|
+
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options:
|
72
|
+
- --main
|
73
|
+
- README
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
hash: 3
|
82
|
+
segments:
|
83
|
+
- 0
|
84
|
+
version: "0"
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
hash: 3
|
91
|
+
segments:
|
92
|
+
- 0
|
93
|
+
version: "0"
|
94
|
+
requirements: []
|
95
|
+
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 1.3.7
|
98
|
+
signing_key:
|
99
|
+
specification_version: 3
|
100
|
+
summary: Ruby partial interpreter written in pure-ruby
|
101
|
+
test_files: []
|
102
|
+
|