[#32945] Shift_JIS variants and UTF-16 support — "U.Nakamura" <usa@...>

こんにちは、なかむら(う)です。

22 messages 2008/01/07
[#32953] Re: Shift_JIS variants and UTF-16 support — Martin Duerst <duerst@...> 2008/01/07

中村さん、こんにちは。

[#32955] Re: Shift_JIS variants and UTF-16 support — Yukihiro Matsumoto <matz@...> 2008/01/07

まつもと ゆきひろです

[#32959] Re: Shift_JIS variants and UTF-16 support — "NARUSE, Yui" <naruse@...> 2008/01/07

成瀬です。

[#32960] Re: Shift_JIS variants and UTF-16 support — Yukihiro Matsumoto <matz@...> 2008/01/07

まつもと ゆきひろです

[#32992] ASCII is alias of US-ASCII; replica of dummy encoding is not a dummy — "NARUSE, Yui" <naruse@...>

成瀬です。

18 messages 2008/01/08
[#32994] Re: ASCII is alias of US-ASCII; replica of dummy encoding is not a dummy — Yukihiro Matsumoto <matz@...> 2008/01/09

まつもと ゆきひろです

[#32995] Re: ASCII is alias of US-ASCII; replica of dummy encoding is not a dummy — Martin Duerst <duerst@...> 2008/01/09

At 18:13 08/01/09, Yukihiro Matsumoto wrote:

[#33011] Re: ASCII is alias of US-ASCII; replica of dummy encoding is not a dummy — "NARUSE, Yui" <naruse@...> 2008/01/11

成瀬です。

[#33012] Re: ASCII is alias of US-ASCII; replica of dummy encoding is not a dummy — Yukihiro Matsumoto <matz@...> 2008/01/11

まつもと ゆきひろです

[#33014] Re: ASCII is alias of US-ASCII; replica of dummy encoding is not a dummy — "NARUSE, Yui" <naruse@...> 2008/01/11

成瀬です。

[#33015] Re: ASCII is alias of US-ASCII; replica of dummy encoding is not a dummy — Yukihiro Matsumoto <matz@...> 2008/01/11

まつもと ゆきひろです

[#33239] Re: [ruby-cvs:22386] Ruby:r15149 (trunk): * string.c (rb_str_each_char): move forward. — Tanaka Akira <akr@...>

In article <200801210259.m0L2x3CW017171@ci.ruby-lang.org>,

11 messages 2008/01/21
[#33240] Re: [ruby-cvs:22386] Ruby:r15149 (trunk): * string.c (rb_str_each_char): move forward. — Nobuyoshi Nakada <nobu@...> 2008/01/21

なかだです。

[#33303] Time#strftimeのエンコーディング — rubikitch@...

るびきちです。

13 messages 2008/01/23
[#33305] Re: Time#strftimeのエンコーディング — Yukihiro Matsumoto <matz@...> 2008/01/23

まつもと ゆきひろです

[#33368] summary of script encoding — "U.Nakamura" <usa@...>

こんにちは、なかむら(う)です。

22 messages 2008/01/25
[#33375] Re: summary of script encoding — Yukihiro Matsumoto <matz@...> 2008/01/25

まつもと ゆきひろです

[#33376] Re: summary of script encoding — "U.Nakamura" <usa@...> 2008/01/25

こんにちは、なかむら(う)です。

[#33387] HashからStructを作る — rubikitch@...

るびきちです。

19 messages 2008/01/25
[#33455] Re: HashからStructを作る — Yukihiro Matsumoto <matz@...> 2008/01/28

まつもと ゆきひろです

[#33505] Re: HashからStructを作る — rubikitch@... 2008/01/29

From: Yukihiro Matsumoto <matz@ruby-lang.org>

[#33507] Re: HashからStructを作る — Yukihiro Matsumoto <matz@...> 2008/01/29

まつもと ゆきひろです

[#33508] Re: HashからStructを作る — rubikitch@... 2008/01/29

From: Yukihiro Matsumoto <matz@ruby-lang.org>

[#33433] Win32OLE: set encoding to OLE string — "U.Nakamura" <usa@...>

こんにちは、なかむら(う)です。

16 messages 2008/01/28

[#33461] Failed to make ruby-1.8.6-p111 on MacOSX 10.5(Leopard) — MORITA Hideyuki <h-morita@...>

=1B$B?9ED$H?=3D$7$^$9!#=1B(B

19 messages 2008/01/28
[#33473] Re: Failed to make ruby-1.8.6-p111 on MacOSX 10.5(Leopard) — Nobuyoshi Nakada <nobu@...> 2008/01/28

なかだです。

[#33503] Re: Failed to make ruby-1.8.6-p111 on MacOSX 10.5(Leopard) — MORITA Hideyuki <h-morita@...> 2008/01/29

森田です。

[#33514] Re: Failed to make ruby-1.8.6-p111 on MacOSX 10.5(Leopard) — Nobuyoshi Nakada <nobu@...> 2008/01/29

なかだです。

[#33518] Re: Failed to make ruby-1.8.6-p111 on MacOSX 10.5(Leopard) — MORITA Hideyuki <h-morita@...> 2008/01/30

森田です。

[#33545] Re: Failed to make ruby-1.8.6-p111 on MacOSX 10.5(Leopard) — Ryutaro Amano <wn9r-amn@...> 2008/01/31

天野竜太郎と申します。

[#33546] Re: Failed to make ruby-1.8.6-p111 on MacOSX 10.5(Leopard) — MORITA Hideyuki <h-morita@...> 2008/01/31

森田です。

[#33547] Re: Failed to make ruby-1.8.6-p111 on MacOSX 10.5(Leopard) — Ryutaro Amano <wn9r-amn@...> 2008/01/31

天野です。

[#33551] Re: Failed to make ruby-1.8.6-p111 on MacOSX 10.5(Leopard) — MORITA Hideyuki <h-morita@...> 2008/01/31

森田です。

[#33488] 現在の script encoding の値を得る方法は? — Hidetoshi NAGAI <nagai@...>

永井@知能.九工大です.

20 messages 2008/01/29
[#33491] Re: 現在の script encoding の値を得る方法は? — Yukihiro Matsumoto <matz@...> 2008/01/29

まつもと ゆきひろです

[#33500] Re: 現在の script encoding の値を得る方法は? — Hidetoshi NAGAI <nagai@...> 2008/01/29

永井@知能.九工大です.

[#33501] Re: 現在の script encoding の値を得る方法は? — "NARUSE, Yui" <naruse@...> 2008/01/29

成瀬です。

[#33515] Re: 現在の script encoding の値を得る方法は? — Hidetoshi NAGAI <nagai@...> 2008/01/30

永井@知能.九工大です.

[#33516] Re: 現在の script encoding の値を得る方法は? — "NARUSE, Yui" <naruse@...> 2008/01/30

成瀬です。

[#33519] Re: 現在の script encoding の値を得る方法は? — Hidetoshi NAGAI <nagai@...> 2008/01/30

永井@知能.九工大です.

[#33522] Re: 現在の script encoding の値を得る方法は? — "NARUSE, Yui" <naruse@...> 2008/01/30

成瀬です。

[ruby-dev:33258] exhaustive test for bignum.c

From: "Yusuke ENDOH" <mame@...>
Date: 2008-01-21 13:56:26 UTC
List: ruby-dev #33258
遠藤と申します。

test_bignum.rb にテストを追加して網羅性を上げてみました。
gcov での bignum.c のカバレッジが 50% から 90% になります。
どうでしょうか。


$ ./ruby test/ruby/test_bignum.rb
Loaded suite test/ruby/test_bignum
Started
........................test/ruby/test_bignum.rb:251: warning: in
a**b, b may be too big
test/ruby/test_bignum.rb:252: warning: in a**b, b may be too big
../home/mame/work/ruby19/gcov/local/lib/ruby/1.9.0/test/unit/assertions.rb:83:
warning: Bignum out of Float range
/home/mame/work/ruby19/gcov/local/lib/ruby/1.9.0/test/unit/assertions.rb:83:
warning: Bignum out of Float range
/home/mame/work/ruby19/gcov/local/lib/ruby/1.9.0/test/unit/assertions.rb:83:
warning: Bignum out of Float range
.......test/ruby/test_bignum.rb:162: warning: Bignum out of Float range
....
Finished in 2.3600356 seconds.

37 tests, 299 assertions, 0 failures, 0 errors


$ gcov bignum.c
File '/usr/include/sys/sysmacros.h'
Lines executed:0.00% of 6
/usr/include/sys/sysmacros.h:creating 'sysmacros.h.gcov'

File './include/ruby/ruby.h'
Lines executed:45.45% of 22
./include/ruby/ruby.h:creating 'ruby.h.gcov'

File 'bignum.c'
Lines executed:93.01% of 1187
bignum.c:creating 'bignum.c.gcov'




Index: test/ruby/test_bignum.rb
===================================================================
--- test/ruby/test_bignum.rb    (revision 15159)
+++ test/ruby/test_bignum.rb    (working copy)
@@ -95,4 +95,257 @@
     assert_equal("1777777777777777777777" ,18446744073709551615.to_s(8))
     assert_equal("-1777777777777777777777" ,-18446744073709551615.to_s(8))
   end
+
+
+  T_ZERO = (2**32).coerce(0).first
+  T_ONE  = (2**32).coerce(1).first
+  T_MONE = (2**32).coerce(-1).first
+  T31  = 2**31   # 2147483648
+  T31P = T31 - 1 # 2147483647
+  T32  = 2**32   # 4294967296
+  T32P = T32 - 1 # 4294967295
+  T64  = 2**64   # 18446744073709551616
+  T64P = T64 - 1 # 18446744073709551615
+
+  def test_big_2comp
+    assert_equal("-4294967296", (~T32P).to_s)
+    assert_equal("..f00000000", "%x" % -T32)
+  end
+
+  def test_int2inum
+    assert_equal([T31P], [T31P].pack("I").unpack("I"))
+    assert_equal([T31P], [T31P].pack("i").unpack("i"))
+  end
+
+  def test_quad_pack
+    assert_equal([    1], [    1].pack("q").unpack("q"))
+    assert_equal([-   1], [-   1].pack("q").unpack("q"))
+    assert_equal([ T31P], [ T31P].pack("q").unpack("q"))
+    assert_equal([-T31P], [-T31P].pack("q").unpack("q"))
+    assert_equal([ T64P], [ T64P].pack("Q").unpack("Q"))
+    assert_equal([    0], [ T64 ].pack("Q").unpack("Q"))
+  end
+
+  def test_str_to_inum
+    assert_equal(1, " +1".to_i)
+    assert_equal(-1, " -1".to_i)
+    assert_equal(0, "++1".to_i)
+    assert_equal(73, "111".oct)
+    assert_equal(273, "0x111".oct)
+    assert_equal(7, "0b111".oct)
+    assert_equal(73, "0o111".oct)
+    assert_equal(111, "0d111".oct)
+    assert_equal(73, "0111".oct)
+    assert_equal(111, Integer("111"))
+    assert_equal(13, "111".to_i(3))
+    assert_raise(ArgumentError) { "111".to_i(37) }
+    assert_equal(1333, "111".to_i(36))
+    assert_equal(1057, "111".to_i(32))
+    assert_equal(0, "00a".to_i)
+    assert_equal(1, Integer("1 "))
+    assert_raise(ArgumentError) { Integer("1_") }
+    assert_raise(ArgumentError) { Integer("1__") }
+    assert_raise(ArgumentError) { Integer("1_0 x") }
+    assert_equal(T31P, "1111111111111111111111111111111".to_i(2))
+  end
+
+  def test_to_s2
+    assert_raise(ArgumentError) { T31P.to_s(37) }
+    assert_equal(32768, (10**32768-1).to_s.size)
+    assert_raise(RangeError) { Process.wait(1, T64P) }
+    assert_equal("0", T_ZERO.to_s)
+    assert_equal("1", T_ONE.to_s)
+  end
+
+  def test_to_f
+    assert_nothing_raised { T31P.to_f.to_i }
+    assert_raise(FloatDomainError) { (1024**1024).to_f.to_i }
+  end
+
+  def test_cmp
+    assert(T31P > 1)
+    assert(T31P < 2147483648.0)
+    assert(T31P < T64P)
+    assert(T64P > T31P)
+    assert_raise(ArgumentError) { T31P < "foo" }
+  end
+
+  def test_eq
+    assert(T31P != 1)
+    assert(T31P == 2147483647.0)
+    assert(T31P != "foo")
+  end
+
+  def test_eql
+    assert(T31P.eql?(T31P))
+  end
+
+  def test_convert
+    assert_equal([255], [T_MONE].pack("C").unpack("C"))
+    assert_equal([0], [T32].pack("C").unpack("C"))
+    assert_raise(RangeError) { 0.to_s(T32) }
+    assert_raise(Errno::EINVAL) { Process.wait(0, T32P) }
+    assert_raise(RangeError) { Process.wait(0, T32) }
+    assert_raise(RangeError) { Process.wait(0, -T32P) }
+  end
+
+  def test_sub
+    assert_equal(-T31, T32 - (T32 + T31))
+  end
+
+  def test_plus
+    assert_equal(T64 + T32, T32 + T64)
+    assert_equal(T32.to_f, T32P + 1.0)
+    assert_raise(TypeError) { T32 + "foo" }
+  end
+
+  def test_minus
+    assert_equal(T32P.to_f, T32 - 1.0)
+    assert_raise(TypeError) { T32 - "foo" }
+  end
+
+  def test_mul
+    assert_equal(T32.to_f, T32 * 1.0)
+    assert_raise(TypeError) { T32 * "foo" }
+  end
+
+  def test_divrem
+    assert_equal(0, T32 / T64)
+  end
+
+  def test_div
+    assert_equal(T32.to_f, T32 / 1.0)
+    assert_raise(TypeError) { T32 / "foo" }
+  end
+
+  def test_modulo
+    assert_raise(TypeError) { T32 % "foo" }
+  end
+
+  def test_remainder
+    assert_equal(0, T32.remainder(1))
+    assert_raise(TypeError) { T32.remainder("foo") }
+  end
+
+  def test_divmod
+    assert_equal([T32, 0], T32.divmod(1))
+    assert_equal([2, 0], T32.divmod(T31))
+    assert_raise(TypeError) { T32.divmod("foo") }
+  end
+
+  def test_quo
+    assert_equal(T32.to_f, T32.quo(1))
+    assert_equal(T32.to_f, T32.quo(1.0))
+    assert_equal(T32.to_f, T32.quo(T_ONE))
+    assert_raise(TypeError) { T32.quo("foo") }
+    assert_equal(1024**1024, (1024**1024).quo(1))
+    assert_equal(1024**1024, (1024**1024).quo(1.0))
+    assert_equal(1024**1024*2, (1024**1024*2).quo(1))
+    inf = 1 / 0.0; nan = inf / inf
+    assert_raise(FloatDomainError) { (1024**1024*2).quo(nan) }
+  end
+
+  def test_pow
+    assert_equal(1.0, T32 ** 0.0)
+    assert_equal(1.0 / T32, T32 ** -1)
+    assert((T32 ** T32).infinite?)
+    assert((T32 ** (2**30-1)).infinite?)
+    assert_raise(TypeError) { T32**"foo" }
+  end
+
+  def test_and
+    assert_equal(0, T32 & 1)
+    assert_equal(-T32, (-T32) & (-T31))
+    assert_equal(0, T32 & T64)
+  end
+
+  def test_or
+    assert_equal(T32 + 1, T32 | 1)
+    assert_equal(T32 + T31, T32 | T31)
+    assert_equal(-T31, (-T32) | (-T31))
+    assert_equal(T64 + T32, T32 | T64)
+  end
+
+  def test_xor
+    assert_equal(T32 + 1, T32 ^ 1)
+    assert_equal(T32 + T31, T32 ^ T31)
+    assert_equal(T31, (-T32) ^ (-T31))
+    assert_equal(T64 + T32, T32 ^ T64)
+  end
+
+  def test_shift2
+    assert_equal(2**33, (2**32) <<  1)
+    assert_equal(2**31, (2**32) << -1)
+    assert_equal(2**33, (2**32) <<  1.0)
+    assert_equal(2**31, (2**32) << -1.0)
+    assert_equal(2**33, (2**32) << T_ONE)
+    assert_equal(2**31, (2**32) << T_MONE)
+    assert_equal(2**31, (2**32) >>  1)
+    assert_equal(2**33, (2**32) >> -1)
+    assert_equal(2**31, (2**32) >>  1.0)
+    assert_equal(2**33, (2**32) >> -1.0)
+    assert_equal(2**31, (2**32) >> T_ONE)
+    assert_equal(2**33, (2**32) >> T_MONE)
+    assert_equal( 0,  (2**32) >> (2**32))
+    assert_equal(-1, -(2**32) >> (2**32))
+    assert_equal( 0,  (2**32) >> 128)
+    assert_equal(-1, -(2**32) >> 128)
+    assert_equal( 0,  (2**31) >> 32)
+    assert_equal(-1, -(2**31) >> 32)
+  end
+
+  def test_aref
+    assert_equal(0, (2**32)[0])
+    assert_equal(0, (2**32)[2**32])
+    assert_equal(0, (2**32)[-(2**32)])
+    assert_equal(0, (2**32)[T_ZERO])
+    assert_equal(0, (-(2**64))[0])
+    assert_equal(1, (-2**256)[256])
+  end
+
+  def test_hash
+    assert_nothing_raised { T31P.hash }
+  end
+
+  def test_coerce
+    assert_equal([T64P, T31P], T31P.coerce(T64P))
+    assert_raise(TypeError) { T31P.coerce(nil) }
+  end
+
+  def test_abs
+    assert_equal(T31P, (-T31P).abs)
+  end
+
+  def test_size
+    assert(T31P.size.is_a?(Integer))
+  end
+
+  def test_odd
+    assert_equal(true, (2**32+1).odd?)
+    assert_equal(false, (2**32).odd?)
+  end
+
+  def test_even
+    assert_equal(false, (2**32+1).even?)
+    assert_equal(true, (2**32).even?)
+  end
+
+  def interrupt
+    time = Time.now
+    start_flag = false
+    end_flag = false
+    thread = Thread.new do
+      start_flag = true
+      yield
+      end_flag = true
+    end
+    sleep 1
+    thread.raise
+    thread.join rescue nil
+    start_flag && !end_flag && Time.now - time < 10
+  end
+
+  def test_interrupt
+    assert(interrupt { (65536 ** 65536).to_s })
+  end
 end

-- 
Yusuke ENDOH <mame@tsg.ne.jp>

In This Thread

Prev Next