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
b4f9b031
Commit
b4f9b031
authored
Nov 22, 2017
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some cosmetic changes
parent
284a1d12
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
32 deletions
+32
-32
benchmark/bm_ao_render.rb
benchmark/bm_ao_render.rb
+15
-15
benchmark/bm_so_lists.rb
benchmark/bm_so_lists.rb
+3
-3
mrbgems/mruby-enumerator/test/enumerator.rb
mrbgems/mruby-enumerator/test/enumerator.rb
+4
-4
test/t/bs_block.rb
test/t/bs_block.rb
+1
-1
test/t/lang.rb
test/t/lang.rb
+7
-7
test/t/string.rb
test/t/string.rb
+2
-2
No files found.
benchmark/bm_ao_render.rb
View file @
b4f9b031
...
...
@@ -68,7 +68,7 @@ class Vec
def
vnormalize
len
=
vlength
v
=
Vec
.
new
(
@x
,
@y
,
@z
)
if
len
>
1.0e-17
then
if
len
>
1.0e-17
v
.
x
=
v
.
x
/
len
v
.
y
=
v
.
y
/
len
v
.
z
=
v
.
z
/
len
...
...
@@ -92,10 +92,10 @@ class Sphere
b
=
rs
.
vdot
(
ray
.
dir
)
c
=
rs
.
vdot
(
rs
)
-
(
@radius
*
@radius
)
d
=
b
*
b
-
c
if
d
>
0.0
then
if
d
>
0.0
t
=
-
b
-
Math
.
sqrt
(
d
)
if
t
>
0.0
and
t
<
isect
.
t
then
if
t
>
0.0
and
t
<
isect
.
t
isect
.
t
=
t
isect
.
hit
=
true
isect
.
pl
=
Vec
.
new
(
ray
.
org
.
x
+
ray
.
dir
.
x
*
t
,
...
...
@@ -118,16 +118,16 @@ class Plane
d
=
-
@p
.
vdot
(
@n
)
v
=
ray
.
dir
.
vdot
(
@n
)
v0
=
v
if
v
<
0.0
then
if
v
<
0.0
v0
=
-
v
end
if
v0
<
1.0e-17
then
if
v0
<
1.0e-17
return
end
t
=
-
(
ray
.
org
.
vdot
(
@n
)
+
d
)
/
v
if
t
>
0.0
and
t
<
isect
.
t
then
if
t
>
0.0
and
t
<
isect
.
t
isect
.
hit
=
true
isect
.
t
=
t
isect
.
n
=
@n
...
...
@@ -170,10 +170,10 @@ end
def
clamp
(
f
)
i
=
f
*
255.5
if
i
>
255.0
then
if
i
>
255.0
i
=
255.0
end
if
i
<
0.0
then
if
i
<
0.0
i
=
0.0
end
i
.
to_i
...
...
@@ -183,11 +183,11 @@ def otherBasis(basis, n)
basis
[
2
]
=
Vec
.
new
(
n
.
x
,
n
.
y
,
n
.
z
)
basis
[
1
]
=
Vec
.
new
(
0.0
,
0.0
,
0.0
)
if
n
.
x
<
0.6
and
n
.
x
>
-
0.6
then
if
n
.
x
<
0.6
and
n
.
x
>
-
0.6
basis
[
1
].
x
=
1.0
elsif
n
.
y
<
0.6
and
n
.
y
>
-
0.6
then
elsif
n
.
y
<
0.6
and
n
.
y
>
-
0.6
basis
[
1
].
y
=
1.0
elsif
n
.
z
<
0.6
and
n
.
z
>
-
0.6
then
elsif
n
.
z
<
0.6
and
n
.
z
>
-
0.6
basis
[
1
].
z
=
1.0
else
basis
[
1
].
x
=
1.0
...
...
@@ -221,8 +221,8 @@ class Scene
p0
=
Vec
.
new
(
isect
.
pl
.
x
+
eps
*
isect
.
n
.
x
,
isect
.
pl
.
y
+
eps
*
isect
.
n
.
y
,
isect
.
pl
.
z
+
eps
*
isect
.
n
.
z
)
nphi
.
times
do
|
j
|
ntheta
.
times
do
|
i
|
nphi
.
times
do
ntheta
.
times
do
r
=
Rand
::
rand
phi
=
2.0
*
3.14159265
*
Rand
::
rand
x
=
Math
.
cos
(
phi
)
*
Math
.
sqrt
(
1.0
-
r
)
...
...
@@ -241,7 +241,7 @@ class Scene
@spheres
[
1
].
intersect
(
ray
,
occisect
)
@spheres
[
2
].
intersect
(
ray
,
occisect
)
@plane
.
intersect
(
ray
,
occisect
)
if
occisect
.
hit
then
if
occisect
.
hit
occlusion
=
occlusion
+
1.0
else
0.0
...
...
@@ -283,7 +283,7 @@ class Scene
@spheres
[
1
].
intersect
(
ray
,
isect
)
@spheres
[
2
].
intersect
(
ray
,
isect
)
@plane
.
intersect
(
ray
,
isect
)
if
isect
.
hit
then
if
isect
.
hit
col
=
ambient_occlusion
(
isect
)
rad
.
x
=
rad
.
x
+
col
.
x
rad
.
y
=
rad
.
y
+
col
.
y
...
...
benchmark/bm_so_lists.rb
View file @
b4f9b031
...
...
@@ -17,19 +17,19 @@ def test_lists()
# li2 must now be empty
# remove each individual item from right side of li3 and
# append to right side of li2 (reversing list)
while
(
not
li3
.
empty?
)
until
li3
.
empty?
li2
.
push
(
li3
.
pop
)
end
# li3 must now be empty
# reverse li1 in place
li1
.
reverse!
# check that first item is now SIZE
if
li1
[
0
]
!=
SIZE
then
if
li1
[
0
]
!=
SIZE
p
"not SIZE"
0
else
# compare li1 and li2 for equality
if
li1
!=
li2
then
if
li1
!=
li2
return
(
0
)
else
# return the length of the list
...
...
mrbgems/mruby-enumerator/test/enumerator.rb
View file @
b4f9b031
...
...
@@ -509,28 +509,28 @@ end
assert
'Hash#select'
do
h
=
{
1
=>
2
,
3
=>
4
,
5
=>
6
}
hret
=
h
.
select
.
with_index
{
|
a
,
b
|
a
[
1
]
==
4
}
hret
=
h
.
select
.
with_index
{
|
a
,
_
b
|
a
[
1
]
==
4
}
assert_equal
({
3
=>
4
},
hret
)
assert_equal
({
1
=>
2
,
3
=>
4
,
5
=>
6
},
h
)
end
assert
'Hash#select!'
do
h
=
{
1
=>
2
,
3
=>
4
,
5
=>
6
}
hret
=
h
.
select!
.
with_index
{
|
a
,
b
|
a
[
1
]
==
4
}
hret
=
h
.
select!
.
with_index
{
|
a
,
_
b
|
a
[
1
]
==
4
}
assert_equal
h
,
hret
assert_equal
({
3
=>
4
},
h
)
end
assert
'Hash#reject'
do
h
=
{
1
=>
2
,
3
=>
4
,
5
=>
6
}
hret
=
h
.
reject
.
with_index
{
|
a
,
b
|
a
[
1
]
==
4
}
hret
=
h
.
reject
.
with_index
{
|
a
,
_
b
|
a
[
1
]
==
4
}
assert_equal
({
1
=>
2
,
5
=>
6
},
hret
)
assert_equal
({
1
=>
2
,
3
=>
4
,
5
=>
6
},
h
)
end
assert
'Hash#reject!'
do
h
=
{
1
=>
2
,
3
=>
4
,
5
=>
6
}
hret
=
h
.
reject!
.
with_index
{
|
a
,
b
|
a
[
1
]
==
4
}
hret
=
h
.
reject!
.
with_index
{
|
a
,
_
b
|
a
[
1
]
==
4
}
assert_equal
h
,
hret
assert_equal
({
1
=>
2
,
5
=>
6
},
h
)
end
...
...
test/t/bs_block.rb
View file @
b4f9b031
...
...
@@ -336,7 +336,7 @@ end
assert
(
'BS Block 28'
)
do
assert_equal
(
10
)
do
3
.
times
{
|
bl
|
3
.
times
{
break
10
}
end
...
...
test/t/lang.rb
View file @
b4f9b031
...
...
@@ -8,7 +8,7 @@
#
# For example, the following mruby code:
#
# if i > 0 and i < 10
then
# if i > 0 and i < 10
#
# compiles to the following byte code:
#
...
...
@@ -27,21 +27,21 @@
assert
(
'and'
,
'11.2.3'
)
do
a
=
1
if
a
>
0
and
a
<
10
then
if
a
>
0
and
a
<
10
b
=
1
else
b
=
0
end
assert_equal
1
,
b
if
a
<
0
and
a
<
10
then
if
a
<
0
and
a
<
10
b
=
1
else
b
=
0
end
assert_equal
0
,
b
if
a
<
0
and
a
>
10
then
if
a
<
0
and
a
>
10
b
=
1
else
b
=
0
...
...
@@ -51,21 +51,21 @@ end
assert
(
'or'
,
'11.2.4'
)
do
a
=
1
if
a
>
0
or
a
<
10
then
if
a
>
0
or
a
<
10
b
=
1
else
b
=
0
end
assert_equal
1
,
b
if
a
<
0
or
a
<
10
then
if
a
<
0
or
a
<
10
b
=
1
else
b
=
0
end
assert_equal
1
,
b
if
a
<
0
or
a
>
10
then
if
a
<
0
or
a
>
10
b
=
1
else
b
=
0
...
...
test/t/string.rb
View file @
b4f9b031
...
...
@@ -367,9 +367,9 @@ assert('String#gsub', '15.2.10.5.18') do
assert_equal
(
'aBcaBc'
,
'abcabc'
.
gsub
(
'b'
,
'B'
),
'gsub without block'
)
assert_equal
(
'aBcaBc'
,
'abcabc'
.
gsub
(
'b'
){
|
w
|
w
.
capitalize
},
'gsub with block'
)
assert_equal
(
'$a$a$'
,
'#a#a#'
.
gsub
(
'#'
,
'$'
),
'mruby/mruby#847'
)
assert_equal
(
'$a$a$'
,
'#a#a#'
.
gsub
(
'#'
){
|
w
|
'$'
},
'mruby/mruby#847 with block'
)
assert_equal
(
'$a$a$'
,
'#a#a#'
.
gsub
(
'#'
){
|
_
w
|
'$'
},
'mruby/mruby#847 with block'
)
assert_equal
(
'$$a$$'
,
'##a##'
.
gsub
(
'##'
,
'$$'
),
'mruby/mruby#847 another case'
)
assert_equal
(
'$$a$$'
,
'##a##'
.
gsub
(
'##'
){
|
w
|
'$$'
},
'mruby/mruby#847 another case with block'
)
assert_equal
(
'$$a$$'
,
'##a##'
.
gsub
(
'##'
){
|
_
w
|
'$$'
},
'mruby/mruby#847 another case with block'
)
assert_equal
(
'A'
,
'a'
.
gsub
(
'a'
,
'A'
))
assert_equal
(
'A'
,
'a'
.
gsub
(
'a'
){
|
w
|
w
.
capitalize
})
assert_equal
(
"<a><><>"
,
'a'
.
gsub
(
'a'
,
'<\0><\1><\2>'
))
...
...
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