diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 11:19:16 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 12:07:37 +0000 |
commit | b485aab7e71c1625cfc27e0f92c9509f42378458 (patch) | |
tree | ae9abe108601079d1679194de237c9a435ae5b55 /web/server/h2o/libh2o/deps/mruby/mrbgems/mruby-sprintf/test/sprintf.rb | |
parent | Adding upstream version 1.44.3. (diff) | |
download | netdata-b485aab7e71c1625cfc27e0f92c9509f42378458.tar.xz netdata-b485aab7e71c1625cfc27e0f92c9509f42378458.zip |
Adding upstream version 1.45.3+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'web/server/h2o/libh2o/deps/mruby/mrbgems/mruby-sprintf/test/sprintf.rb')
-rw-r--r-- | web/server/h2o/libh2o/deps/mruby/mrbgems/mruby-sprintf/test/sprintf.rb | 109 |
1 files changed, 0 insertions, 109 deletions
diff --git a/web/server/h2o/libh2o/deps/mruby/mrbgems/mruby-sprintf/test/sprintf.rb b/web/server/h2o/libh2o/deps/mruby/mrbgems/mruby-sprintf/test/sprintf.rb deleted file mode 100644 index e3b66ef9c..000000000 --- a/web/server/h2o/libh2o/deps/mruby/mrbgems/mruby-sprintf/test/sprintf.rb +++ /dev/null @@ -1,109 +0,0 @@ -#assert('Kernel.sprintf') do -#end - -assert('String#%') do - assert_equal "one=1", "one=%d" % 1 - assert_equal "1 one 1.0", "%d %s %3.1f" % [ 1, "one", 1.01 ] - assert_equal "123 < 456", "%{num} < %<str>s" % { num: 123, str: "456" } - assert_equal 15, ("%b" % (1<<14)).size -end - -assert('String#% with inf') do - inf = Float::INFINITY - - assert_equal "Inf", "%f" % inf - assert_equal "Inf", "%2f" % inf - assert_equal "Inf", "%3f" % inf - assert_equal " Inf", "%4f" % inf - assert_equal " Inf", "%5f" % inf - - assert_equal "+Inf", "%+f" % inf - assert_equal "+Inf", "%+2f" % inf - assert_equal "+Inf", "%+3f" % inf - assert_equal "+Inf", "%+4f" % inf - assert_equal " +Inf", "%+5f" % inf - - assert_equal "Inf", "%-f" % inf - assert_equal "Inf", "%-2f" % inf - assert_equal "Inf", "%-3f" % inf - assert_equal "Inf ", "%-4f" % inf - assert_equal "Inf ", "%-5f" % inf - - assert_equal " Inf", "% f" % inf - assert_equal " Inf", "% 2f" % inf - assert_equal " Inf", "% 3f" % inf - assert_equal " Inf", "% 4f" % inf - assert_equal " Inf", "% 5f" % inf -end - -assert('String#% with nan') do - nan = Float::NAN - - assert_equal "NaN", "%f" % nan - assert_equal "NaN", "%2f" % nan - assert_equal "NaN", "%3f" % nan - assert_equal " NaN", "%4f" % nan - assert_equal " NaN", "%5f" % nan - - assert_equal "+NaN", "%+f" % nan - assert_equal "+NaN", "%+2f" % nan - assert_equal "+NaN", "%+3f" % nan - assert_equal "+NaN", "%+4f" % nan - assert_equal " +NaN", "%+5f" % nan - - assert_equal "NaN", "%-f" % nan - assert_equal "NaN", "%-2f" % nan - assert_equal "NaN", "%-3f" % nan - assert_equal "NaN ", "%-4f" % nan - assert_equal "NaN ", "%-5f" % nan - - assert_equal " NaN", "% f" % nan - assert_equal " NaN", "% 2f" % nan - assert_equal " NaN", "% 3f" % nan - assert_equal " NaN", "% 4f" % nan - assert_equal " NaN", "% 5f" % nan -end - -assert("String#% with invalid chr") do - begin - class Fixnum - alias_method :chr_, :chr if method_defined?(:chr) - - def chr - nil - end - end - - assert_raise TypeError do - "%c" % 0x80 - end - ensure - class Fixnum - if method_defined?(:chr_) - alias_method :chr, :chr_ - remove_method :chr_ - end - end - end -end - -assert("String#% %b") do - assert_equal("..10115", "%0b5" % -5) -end - -assert("String#% %d") do - assert_equal(" 10", "%4d" % 10) - assert_equal("1000", "%4d" % 1000) - assert_equal("10000", "%4d" % 10000) -end - -assert("String#% invalid format") do - assert_raise ArgumentError do - "%?" % "" - end -end - -assert("String#% invalid format shared substring") do - fmt = ("x"*30+"%!")[0...-1] - assert_equal fmt, sprintf(fmt, "") -end |