nendo 0.6.6 → 0.6.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/Rakefile +2 -3
- data/VERSION.yml +1 -1
- data/lib/nendo/init.nnd +7 -3
- data/lib/nendo/init.nndc +62 -28
- data/lib/nendo/nendo/experimental.nndc +6 -6
- data/lib/nendo/ruby/builtin_functions.rb +13 -3
- data/lib/nendo/ruby/core.rb +1 -1
- data/lib/nendo/ruby/evaluator.rb +64 -24
- data/lib/nendo/ruby/out_of_module.rb +2 -5
- data/lib/nendo/ruby/reader.rb +1 -2
- data/lib/nendo/ruby/types.rb +24 -0
- data/lib/nendo/srfi-2.nndc +1 -1
- data/lib/nendo/srfi-26.nndc +3 -3
- data/lib/nendo/text/html-lite.nndc +1 -1
- data/lib/nendo/util/combinations.nndc +4 -4
- data/lib/nendo/util/list.nndc +1 -1
- data/lib/nendo/util/match.nndc +33 -33
- data/test/nendo_spec.rb +1 -2158
- data/test/nendo_spec_2.rb +2128 -0
- data/test/nendo_spec_3.rb +105 -0
- metadata +10 -92
@@ -0,0 +1,105 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- encoding: utf-8 -*-
|
3
|
+
#
|
4
|
+
# nendo_spec.rb - "RSpec file for nendo language"
|
5
|
+
#
|
6
|
+
# Copyright (c) 2009-2011 Kiyoka Nishiyama <kiyoka@sumibi.org>
|
7
|
+
#
|
8
|
+
# Redistribution and use in source and binary forms, with or without
|
9
|
+
# modification, are permitted provided that the following conditions
|
10
|
+
# are met:
|
11
|
+
#
|
12
|
+
# 1. Redistributions of source code must retain the above copyright
|
13
|
+
# notice, this list of conditions and the following disclaimer.
|
14
|
+
#
|
15
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
16
|
+
# notice, this list of conditions and the following disclaimer in the
|
17
|
+
# documentation and/or other materials provided with the distribution.
|
18
|
+
#
|
19
|
+
# 3. Neither the name of the authors nor the names of its contributors
|
20
|
+
# may be used to endorse or promote products derived from this
|
21
|
+
# software without specific prior written permission.
|
22
|
+
#
|
23
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
24
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
25
|
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
26
|
+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
27
|
+
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
28
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
29
|
+
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
30
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
31
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
32
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
33
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
34
|
+
#
|
35
|
+
require 'nendo'
|
36
|
+
include Nendo
|
37
|
+
|
38
|
+
describe Nendo, "When use optional argument parser " do
|
39
|
+
before do
|
40
|
+
@nendo = Nendo::Core.new()
|
41
|
+
@nendo.loadInitFile
|
42
|
+
end
|
43
|
+
it "should" do
|
44
|
+
@nendo.evalStr( " (get-optional '() 100) " ).should == "100"
|
45
|
+
@nendo.evalStr( " (get-optional '(1) 100) " ).should == "1"
|
46
|
+
@nendo.evalStr( " (get-optional '(2) 100) " ).should == "2"
|
47
|
+
@nendo.evalStr( " (get-optional '(3 4) 100) " ).should == "3"
|
48
|
+
@nendo.evalStr( " (get-optional '() #t) " ).should == "#t"
|
49
|
+
@nendo.evalStr( " (get-optional '() #f) " ).should == "#f"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe Nendo, "When use :optional argument feature " do
|
54
|
+
before do
|
55
|
+
@nendo = Nendo::Core.new()
|
56
|
+
@nendo.setDisplayErrors( false )
|
57
|
+
@nendo.loadInitFile
|
58
|
+
end
|
59
|
+
it "should" do
|
60
|
+
@nendo.evalStr( '(define (func arg1 arg2) (list arg1 arg2)) (func 1 2)' ).should == "(1 2)"
|
61
|
+
@nendo.evalStr( '(define (func arg1 arg2 :optional (arg3 #f)) (list arg1 arg2 arg3)) (func 1 2)' ).should == "(1 2 #f)"
|
62
|
+
@nendo.evalStr( '(define (func arg1 arg2 :optional (arg3 #t)) (list arg1 arg2 arg3)) (func 1 2)' ).should == "(1 2 #t)"
|
63
|
+
@nendo.evalStr( '(define (func arg1 arg2 :optional (arg3 3)) (list arg1 arg2 arg3)) (func 1 2)' ).should == "(1 2 3)"
|
64
|
+
@nendo.evalStr( '(define (func arg1 arg2 :optional (arg3 #f)) (list arg1 arg2 arg3)) (func 1 2 30)' ).should == "(1 2 30)"
|
65
|
+
@nendo.evalStr( '(define (func arg1 arg2 :optional (arg3 #t)) (list arg1 arg2 arg3)) (func 1 2 40)' ).should == "(1 2 40)"
|
66
|
+
@nendo.evalStr( '(define (func arg1 arg2 :optional (arg3 3)) (list arg1 arg2 arg3)) (func 1 2 50)' ).should == "(1 2 50)"
|
67
|
+
@nendo.evalStr( '(define (func arg1 arg2 :optional (arg3 3)) (list arg1 arg2 arg3)) (func 1 2 "String")' ).should == '(1 2 "String")'
|
68
|
+
|
69
|
+
@nendo.evalStr( '(define func (lambda (arg1 arg2) (list arg1 arg2))) (func 1 2)' ).should == '(1 2)'
|
70
|
+
lambda { @nendo.evalStr( '(define func (lambda (arg1 arg2 :optional (arg3 #f)) (list arg1 arg2 arg3))) (func 1 2)' ) }.should raise_error( RuntimeError, /handle keyword argument/ )
|
71
|
+
lambda { @nendo.evalStr( '(define func (lambda (arg1 arg2 :optional (arg3 #t)) (list arg1 arg2 arg3))) (func 1 2)' ) }.should raise_error( RuntimeError, /handle keyword argument/ )
|
72
|
+
lambda { @nendo.evalStr( '(define func (lambda (arg1 arg2 :optional (arg3 3)) (list arg1 arg2 arg3))) (func 1 2)' ) }.should raise_error( RuntimeError, /handle keyword argument/ )
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
describe Nendo, "when use export-to-ruby macro " do
|
78
|
+
before do
|
79
|
+
@nendo = Nendo::Core.new()
|
80
|
+
@nendo.setDisplayErrors( false )
|
81
|
+
@nendo.loadInitFile
|
82
|
+
end
|
83
|
+
it "should" do
|
84
|
+
@nendo.evalStr( " (define (nendo_function0 ) 0) #t" ).should == "#t"
|
85
|
+
@nendo.evalStr( " (define (nendo_function1 x) (+ x 1)) #t" ).should == "#t"
|
86
|
+
@nendo.evalStr( " (define (nendo_function2 x y) (* x y)) #t" ).should == "#t"
|
87
|
+
@nendo.evalStr( " (define (nendo_function7 a b c d e f g) (to-arr (list a b c d e f g))) #t" ).should == "#t"
|
88
|
+
@nendo.evalStr( " (export-to-ruby nendo_function0) " ).should == "#t"
|
89
|
+
@nendo.evalStr( " (export-to-ruby nendo_function1) " ).should == "#t"
|
90
|
+
@nendo.evalStr( " (export-to-ruby nendo_function2) " ).should == "#t"
|
91
|
+
@nendo.evalStr( " (export-to-ruby nendo_function7) " ).should == "#t"
|
92
|
+
@nendo.evalStr( " (macroexpand '(export-to-ruby nendo_function1)) " ).should == '(%export-to-ruby "nendo_function1" nendo_function1)'
|
93
|
+
@nendo.evalStr( " (macroexpand '(export-to-ruby nendo_function7)) " ).should == '(%export-to-ruby "nendo_function7" nendo_function7)'
|
94
|
+
@nendo.evalStr( " (define (a-func0) 0) #t" ).should == "#t"
|
95
|
+
lambda { @nendo.evalStr( " (export-to-ruby a-func0) " ) }.should raise_error(ArgumentError)
|
96
|
+
@nendo.evalStr( " (define (clone) 0) #t" ).should == "#t"
|
97
|
+
lambda { @nendo.evalStr( " (export-to-ruby clone) " ) }.should raise_error(RuntimeError)
|
98
|
+
@nendo.evalStr( " (define variable_a 0) #t" ).should == "#t"
|
99
|
+
lambda { @nendo.evalStr( " (export-to-ruby variable_a) " ) }.should raise_error(ArgumentError)
|
100
|
+
@nendo.nendo_function0.should == 0
|
101
|
+
@nendo.nendo_function1( 10 ).should == 11
|
102
|
+
@nendo.nendo_function2( 8, 9 ).should == 72
|
103
|
+
@nendo.nendo_function7( 7,6,5,4,3,2,1 ).should === [ 7,6,5,4,3,2,1 ]
|
104
|
+
end
|
105
|
+
end
|
metadata
CHANGED
@@ -1,99 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nendo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kiyoka Nishiyama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: rspec
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ! '>='
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ! '>='
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ! '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ! '>='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: json
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ! '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ! '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ! '>='
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rake
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ! '>='
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ! '>='
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: json
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ! '>='
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ! '>='
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
11
|
+
date: 2014-02-03 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
97
13
|
description: Nendo is a programming language written in Ruby.
|
98
14
|
email: kiyoka@sumibi.org
|
99
15
|
executables:
|
@@ -102,7 +18,7 @@ extensions: []
|
|
102
18
|
extra_rdoc_files:
|
103
19
|
- README.md
|
104
20
|
files:
|
105
|
-
- .gemtest
|
21
|
+
- ".gemtest"
|
106
22
|
- COPYING
|
107
23
|
- History.txt
|
108
24
|
- README.md
|
@@ -170,6 +86,8 @@ files:
|
|
170
86
|
- test/match-test.nnd
|
171
87
|
- test/nendo-util-test.nnd
|
172
88
|
- test/nendo_spec.rb
|
89
|
+
- test/nendo_spec_2.rb
|
90
|
+
- test/nendo_spec_3.rb
|
173
91
|
- test/rspec_formatter_for_emacs.rb
|
174
92
|
- test/srfi-1-test.nnd
|
175
93
|
- test/srfi-2-test.nnd
|
@@ -185,23 +103,23 @@ licenses:
|
|
185
103
|
metadata: {}
|
186
104
|
post_install_message:
|
187
105
|
rdoc_options:
|
188
|
-
- -x
|
106
|
+
- "-x"
|
189
107
|
- match.nndc
|
190
108
|
require_paths:
|
191
109
|
- lib
|
192
110
|
required_ruby_version: !ruby/object:Gem::Requirement
|
193
111
|
requirements:
|
194
|
-
- -
|
112
|
+
- - ">="
|
195
113
|
- !ruby/object:Gem::Version
|
196
114
|
version: '0'
|
197
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
198
116
|
requirements:
|
199
|
-
- -
|
117
|
+
- - ">="
|
200
118
|
- !ruby/object:Gem::Version
|
201
119
|
version: '0'
|
202
120
|
requirements: []
|
203
121
|
rubyforge_project:
|
204
|
-
rubygems_version: 2.0
|
122
|
+
rubygems_version: 2.2.0
|
205
123
|
signing_key:
|
206
124
|
specification_version: 4
|
207
125
|
summary: Nendo is a dialect of Lisp.
|