diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-11-22 16:09:50 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-11-22 16:09:50 +0900 |
| commit | b4f9b031deaf7c75dad7aa10f2318bb37e268fa3 (patch) | |
| tree | 6e38cc9b61330d34d09e157bca406dc1b084198c | |
| parent | 284a1d12ee6b0fdd77b042771f5db833112fc14e (diff) | |
| download | mruby-b4f9b031deaf7c75dad7aa10f2318bb37e268fa3.tar.gz mruby-b4f9b031deaf7c75dad7aa10f2318bb37e268fa3.zip | |
Some cosmetic changes
| -rw-r--r-- | benchmark/bm_ao_render.rb | 30 | ||||
| -rw-r--r-- | benchmark/bm_so_lists.rb | 6 | ||||
| -rw-r--r-- | mrbgems/mruby-enumerator/test/enumerator.rb | 8 | ||||
| -rw-r--r-- | test/t/bs_block.rb | 2 | ||||
| -rwxr-xr-x | test/t/lang.rb | 14 | ||||
| -rw-r--r-- | test/t/string.rb | 4 |
6 files changed, 32 insertions, 32 deletions
diff --git a/benchmark/bm_ao_render.rb b/benchmark/bm_ao_render.rb index 8212c3a13..dc4388c7d 100644 --- a/benchmark/bm_ao_render.rb +++ b/benchmark/bm_ao_render.rb @@ -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 = [email protected](@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 diff --git a/benchmark/bm_so_lists.rb b/benchmark/bm_so_lists.rb index e8f4a2a5f..512e312cc 100644 --- a/benchmark/bm_so_lists.rb +++ b/benchmark/bm_so_lists.rb @@ -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 diff --git a/mrbgems/mruby-enumerator/test/enumerator.rb b/mrbgems/mruby-enumerator/test/enumerator.rb index 37169ade9..4c904a81d 100644 --- a/mrbgems/mruby-enumerator/test/enumerator.rb +++ b/mrbgems/mruby-enumerator/test/enumerator.rb @@ -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 diff --git a/test/t/bs_block.rb b/test/t/bs_block.rb index 04a4a15ba..62eb7e32e 100644 --- a/test/t/bs_block.rb +++ b/test/t/bs_block.rb @@ -336,7 +336,7 @@ end assert('BS Block 28') do assert_equal(10) do - 3.times{|bl| + 3.times{ break 10 } end diff --git a/test/t/lang.rb b/test/t/lang.rb index 57c375643..c28bcfa92 100755 --- a/test/t/lang.rb +++ b/test/t/lang.rb @@ -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
diff --git a/test/t/string.rb b/test/t/string.rb index c9041469e..6351d5d98 100644 --- a/test/t/string.rb +++ b/test/t/string.rb @@ -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>')) |
