Permalink
Browse files

Add test

  • Loading branch information...
1 parent c39798f commit 4e7e2768251ef8e617998b8eea763ecbaf259ab9 @matsumoto-r committed Dec 28, 2012
Showing with 23 additions and 37 deletions.
  1. +7 −4 example/random.rb
  2. +0 −33 test/ramdom.rb
  3. +16 −0 test/random.rb
View
11 example/random.rb
@@ -1,13 +1,16 @@
r = Random.new();
r.srand(10)
-puts r.rand()
+hoge = r.rand()
r.srand(20)
-puts r.rand()
+fuga = r.rand()
r.srand(10)
-puts r.rand()
+foo = r.rand()
-100.times do |i|
+puts hoge == fuga
+puts hoge == foo
+
+3.times do |i|
puts r.rand()
puts r.rand(0)
puts r.rand(10)
View
33 test/ramdom.rb
@@ -1,33 +0,0 @@
-assert('parse object') do
- JSON.parse('{"foo": "bar"}') == {"foo"=>"bar"}
-end
-assert('parse array') do
- JSON.parse('[true, "foo"]')[1] == "foo"
-end
-assert('stringify boolean') do
- JSON.stringify(true) == "true"
-end
-assert('strnigify object with numeric value') do
- JSON.stringify({"foo"=>"bar"}) == '{"foo":"bar"}'
-end
-assert('strnigify object with string value') do
- JSON.stringify({"foo"=> 1}) == '{"foo":1}'
-end
-assert('stringify object with float value') do
- JSON.stringify({"foo"=> 2.3}) == '{"foo":2.3}'
-end
-assert('stringify object with boolean key and float value') do
- JSON.stringify({true=> 3.4}) == '{"true":3.4}'
-end
-assert('stringify object with object key and float value') do
- JSON.stringify({{"foo"=> "bar"}=> 1.2}) == '{"{\"foo\"=>\"bar\"}":1.2}'
-end
-assert('stringify empty array') do
- JSON.stringify([]) == "[]"
-end
-assert('strnigify array with few elements') do
- JSON.stringify([1,true,"foo"]) == "[1,true,\"foo\"]"
-end
-assert('stringify object with several keys') do
- JSON.stringify({"foo"=>1, "bar"=> 2}) == '{"foo":1,"bar":2}'
-end
View
16 test/random.rb
@@ -0,0 +1,16 @@
+r = Random.new();
+
+r.srand(10)
+hoge = r.rand()
+r.srand(20)
+fuga = r.rand()
+r.srand(10)
+foo = r.rand()
+
+assert('srand and rand 1') do
+ hoge != fuga
+end
+
+assert('srand and rand 2') do
+ hoge == foo
+end

0 comments on commit 4e7e276

Please sign in to comment.