summaryrefslogtreecommitdiff
path: root/trunk/test/scanf/test_scanfblocks.rb
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-25 15:13:14 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-25 15:13:14 +0000
commitd0233291bc8a5068e52c69c210e5979e5324b5bc (patch)
tree7d9459449c33792c63eeb7baa071e76352e0baab /trunk/test/scanf/test_scanfblocks.rb
parent0dc342de848a642ecce8db697b8fecd83a63e117 (diff)
parent72eaacaa15256ab95c3b52ea386f88586fb9da40 (diff)
re-adding tag v1_9_0_4 as an alias of trunk@18848v1_9_0_4
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_9_0_4@18849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'trunk/test/scanf/test_scanfblocks.rb')
-rw-r--r--trunk/test/scanf/test_scanfblocks.rb81
1 files changed, 0 insertions, 81 deletions
diff --git a/trunk/test/scanf/test_scanfblocks.rb b/trunk/test/scanf/test_scanfblocks.rb
deleted file mode 100644
index 907a3c2838..0000000000
--- a/trunk/test/scanf/test_scanfblocks.rb
+++ /dev/null
@@ -1,81 +0,0 @@
-# $Id$
-#
-# scanf for Ruby
-#
-# Some not very comprehensive tests of block behavior.
-
-
-require 'test/unit'
-require 'scanf'
-require 'tmpdir'
-
-class TestScanfBlock < Test::Unit::TestCase
-
- def setup
- @str = <<-EOS
- Beethoven 1770
- Bach 1685
- Handel 1685
- Scarlatti 1685
- Brahms 1833
- EOS
- end
-
-alias set_up setup
- def test_str1
- res = @str.scanf("%s%d") { |name, year| "#{name} was born in #{year}." }
- assert_equal(res,
- [ "Beethoven was born in 1770.",
- "Bach was born in 1685.",
- "Handel was born in 1685.",
- "Scarlatti was born in 1685.",
- "Brahms was born in 1833." ])
- end
-
- def test_str2
- names = @str.scanf("%s%d") { |name, year| name.upcase }
- assert_equal(names, ["BEETHOVEN", "BACH", "HANDEL", "SCARLATTI", "BRAHMS"])
- end
-
- def test_str3
- assert_equal("".scanf("%d%f%s") {}, [])
- end
-
- def test_str4
- assert_equal("abc".scanf("%d%f%s") {}, [])
- end
-
- def test_str5
- assert_equal("abc".scanf("") {}, [])
- end
-
- def test_io1
- fn = "#{Dir.tmpdir}/iotest.dat.#{$$}"
- File.open(fn, "w") { |fh| fh.puts(@str) }
- fh = File.open(fn, "rb")
- res = fh.scanf("%s%d") { |name, year| "#{name} was born in #{year}." }
-
- assert_equal(
- [ "Beethoven was born in 1770.",
- "Bach was born in 1685.",
- "Handel was born in 1685.",
- "Scarlatti was born in 1685.",
- "Brahms was born in 1833." ],res)
- fh.close
- ensure
- File.delete(fn)
- end
-
- def test_io2
- fn = "#{Dir.tmpdir}/iotest.dat.#{$$}"
- File.open(fn, "w").close
- fh = File.open(fn,"rb")
- assert_equal(fh.scanf("") {}, [])
- fh.seek(0)
- assert_equal(fh.scanf("%d%f%s") {}, [])
- fh.close
- ensure
- File.delete(fn)
- end
-
-end