nendo 0.6.8 → 0.7.0

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.
data/test/nendo_spec_3.rb DELETED
@@ -1,105 +0,0 @@
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
@@ -1,26 +0,0 @@
1
- require 'rspec/core/formatters/progress_formatter'
2
-
3
- # Example of a formatter with custom bactrace printing. Run me with:
4
- # ruby bin/spec xxxxx.rb -r ./test/rspec_formatter_for_emacs.rb -f CustomFormatter
5
- class CustomFormatter < RSpec::Core::Formatters::ProgressFormatter
6
- def backtrace_line(line)
7
- return nil if configuration.cleaned_from_backtrace?(line)
8
- str = line.gsub(/([^:]*\.rb):([0-9]+):in /) do
9
- path = "#{$1}"
10
- lineno = "#{$2}"
11
- if path.match( /lib/ ) and path.match( /rspec/ )
12
- "#{File.expand_path(path)}:#{lineno} IN "
13
- else
14
- "#{File.expand_path(path)}:#{lineno}:in "
15
- end
16
- end
17
- str
18
- end
19
-
20
- def dump_backtrace(example)
21
- format_backtrace(example.execution_result[:exception].backtrace, example).each do |backtrace_info|
22
- output.puts cyan(" #{backtrace_info}")
23
- end
24
- end
25
-
26
- end