Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
0aa5aa1d
Commit
0aa5aa1d
authored
Jan 29, 2020
by
dearblue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for top level local variables are in file scope; ref #4931
parent
25d9370f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
0 deletions
+38
-0
mrbgems/mruby-bin-mirb/bintest/mirb.rb
mrbgems/mruby-bin-mirb/bintest/mirb.rb
+17
-0
mrbgems/mruby-bin-mruby/bintest/mruby.rb
mrbgems/mruby-bin-mruby/bintest/mruby.rb
+21
-0
No files found.
mrbgems/mruby-bin-mirb/bintest/mirb.rb
View file @
0aa5aa1d
...
...
@@ -32,3 +32,20 @@ EOS
o
,
_
=
Open3
.
capture2
(
"bin/mirb -r
#{
lib
.
path
}
"
,
:stdin_data
=>
"Hoge.new.hoge
\n
"
)
assert_true
o
.
include?
(
'=> :hoge'
)
end
assert
(
'top level local variables are in file scope'
)
do
lib
=
Tempfile
.
new
(
'lib.rb'
)
lib
.
write
<<-
TESTLIB
a = 1
A = -> { a }
TESTLIB
lib
.
flush
o
,
_
=
Open3
.
capture2
(
"bin/mirb -r
#{
lib
.
path
}
"
,
:stdin_data
=>
<<-
TESTCODE
)
a
a = 5
A.call
TESTCODE
assert_kind_of
Integer
,
o
=~
/\bundefined method 'a' \(NoMethodError\).*=> 5\b.*=> 1\b/m
end
mrbgems/mruby-bin-mruby/bintest/mruby.rb
View file @
0aa5aa1d
...
...
@@ -162,3 +162,24 @@ assert('codegen error') do
code
=
"def f(
#{
(
1
..
100
).
map
{
|
n
|
"a
#{
n
}
"
}
* "
,
"}); end"
assert_mruby
(
""
,
/\Acodegen error:.*\n\z/
,
false
,
[
"-e"
,
code
])
end
assert
(
'top level local variables are in file scope'
)
do
arb
,
amrb
=
Tempfile
.
new
(
'a.rb'
),
Tempfile
.
new
(
'a.mrb'
)
brb
,
bmrb
=
Tempfile
.
new
(
'b.rb'
),
Tempfile
.
new
(
'b.mrb'
)
crb
,
cmrb
=
Tempfile
.
new
(
'c.rb'
),
Tempfile
.
new
(
'c.mrb'
)
drb
,
dmrb
=
Tempfile
.
new
(
'd.rb'
),
Tempfile
.
new
(
'd.mrb'
)
File
.
write
arb
.
path
,
'a = 1'
system
"
#{
cmd
(
'mrbc'
)
}
-g -o
#{
amrb
.
path
}
#{
arb
.
path
}
"
File
.
write
brb
.
path
,
'p a'
system
"
#{
cmd
(
'mrbc'
)
}
-g -o
#{
bmrb
.
path
}
#{
brb
.
path
}
"
assert_mruby
(
""
,
/:1: undefined method 'a' \(NoMethodError\)\n\z/
,
false
,
[
"-r"
,
arb
.
path
,
brb
.
path
])
assert_mruby
(
""
,
/:1: undefined method 'a' \(NoMethodError\)\n\z/
,
false
,
[
"-b"
,
"-r"
,
amrb
.
path
,
bmrb
.
path
])
File
.
write
crb
.
path
,
'a, b, c = 1, 2, 3; A = -> { b = -2; [a, b, c] }'
system
"
#{
cmd
(
'mrbc'
)
}
-g -o
#{
cmrb
.
path
}
#{
crb
.
path
}
"
File
.
write
drb
.
path
,
'a, b = 5, 6; p A.call; p a, b'
system
"
#{
cmd
(
'mrbc'
)
}
-g -o
#{
dmrb
.
path
}
#{
drb
.
path
}
"
assert_mruby
(
"[1, -2, 3]
\n
5
\n
6
\n
"
,
""
,
true
,
[
"-r"
,
crb
.
path
,
drb
.
path
])
assert_mruby
(
"[1, -2, 3]
\n
5
\n
6
\n
"
,
""
,
true
,
[
"-b"
,
"-r"
,
cmrb
.
path
,
dmrb
.
path
])
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment