code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
begin
require "readline"
=begin
class << Readline::HISTORY
def []=(index, str)
raise NotImplementedError
end
def pop
raise NotImplementedError
end
def shift
raise NotImplementedError
end
def delete_at(index)
raise NotImplementedError
end
end
=end
=begin
... | Ruby |
begin
require "readline"
=begin
class << Readline
[
"line_buffer",
"point",
"set_screen_size",
"get_screen_size",
"vi_editing_mode",
"emacs_editing_mode",
"completion_append_character=",
"completion_append_character",
"basic_word_break_characters=",
"basic_word_... | Ruby |
require_relative "utils"
require "webrick"
require "test/unit"
class TestWEBrickCGI < Test::Unit::TestCase
CRLF = "\r\n"
def start_cgi_server(&block)
config = {
:CGIInterpreter => TestWEBrick::RubyBin,
:DocumentRoot => File.dirname(__FILE__),
:DirectoryIndex => ["webrick.cgi"],
:Reques... | Ruby |
require "test/unit"
require "webrick/httpversion"
class TestWEBrickHTTPVersion < Test::Unit::TestCase
def setup
@v09 = WEBrick::HTTPVersion.new("0.9")
@v10 = WEBrick::HTTPVersion.new("1.0")
@v11 = WEBrick::HTTPVersion.new("1.001")
end
def test_to_s()
assert_equal("0.9", @v09.to_s)
assert_equ... | Ruby |
#!ruby -d
require "webrick/cgi"
class TestApp < WEBrick::CGI
def do_GET(req, res)
res["content-type"] = "text/plain"
if (p = req.path_info) && p.length > 0
res.body = p
elsif (q = req.query).size > 0
res.body = q.keys.sort.collect{|key|
q[key].list.sort.collect{|v|
"#{key}=#... | Ruby |
require "test/unit"
require "net/http"
require "webrick"
require_relative "utils"
class TestWEBrickHTTPServer < Test::Unit::TestCase
def test_mount
httpd = WEBrick::HTTPServer.new(
:Logger => WEBrick::Log.new(TestWEBrick::NullWriter),
:DoNotListen=>true
)
httpd.mount("/", :Root)
httpd.mou... | Ruby |
#!ruby -d
require "webrick/cgi"
class TestApp < WEBrick::CGI
def do_GET(req, res)
res["content-type"] = "text/plain"
if (p = req.path_info) && p.length > 0
res.body = p
elsif (q = req.query).size > 0
res.body = q.keys.sort.collect{|key|
q[key].list.sort.collect{|v|
"#{key}=#... | Ruby |
require "test/unit"
require "webrick/utils"
class TestWEBrickUtils < Test::Unit::TestCase
def assert_expired(flag, m)
if m == WEBrick::Utils
handler = WEBrick::Utils::TimeoutHandler.instance
assert_equal(flag, handler.instance_eval{ @timeout_info.empty? })
end
end
def do_test_timeout(m)
... | Ruby |
require_relative '../ruby/envutil'
require "webrick"
begin
require "webrick/https"
rescue LoadError
end
require "webrick/httpproxy"
module TestWEBrick
NullWriter = Object.new
def NullWriter.<<(msg)
puts msg if $DEBUG
return self
end
RubyBin = "\"#{EnvUtil.rubybin}\""
RubyBin << " --disable-gems"
... | Ruby |
require "test/unit"
require_relative "utils.rb"
require "webrick"
require "stringio"
class WEBrick::TestFileHandler < Test::Unit::TestCase
def default_file_handler(filename)
klass = WEBrick::HTTPServlet::DefaultFileHandler
klass.new(WEBrick::Config::HTTP, filename)
end
def windows?
File.directory?("... | Ruby |
require "test/unit"
require "net/http"
require "tempfile"
require "webrick"
require "webrick/httpauth/basicauth"
require_relative "utils"
class TestWEBrickHTTPAuth < Test::Unit::TestCase
def test_basic_auth
TestWEBrick.start_httpserver{|server, addr, port, log|
realm = "WEBrick's realm"
path = "/basi... | Ruby |
require "test/unit"
require "webrick/httputils"
class TestWEBrickHTTPUtils < Test::Unit::TestCase
include WEBrick::HTTPUtils
def test_normilize_path
assert_equal("/foo", normalize_path("/foo"))
assert_equal("/foo/bar/", normalize_path("/foo/bar/"))
assert_equal("/", normalize_path("/f... | Ruby |
require "test/unit"
require "net/http"
require "webrick"
require "webrick/httpproxy"
begin
require "webrick/ssl"
require "net/https"
require File.expand_path("../openssl/utils.rb", File.dirname(__FILE__))
rescue LoadError
# test_connect will be skipped
end
require File.expand_path("utils.rb", File.dirname(__FIL... | Ruby |
require "test/unit"
require "tempfile"
require "webrick"
require_relative "utils"
class TestWEBrickServer < Test::Unit::TestCase
class Echo < WEBrick::GenericServer
def run(sock)
while line = sock.gets
sock << line
end
end
end
def test_server
TestWEBrick.start_server(Echo){|serve... | Ruby |
require "test/unit"
require "webrick/cookie"
class TestWEBrickCookie < Test::Unit::TestCase
def test_new
cookie = WEBrick::Cookie.new("foo","bar")
assert_equal("foo", cookie.name)
assert_equal("bar", cookie.value)
assert_equal("foo=bar", cookie.to_s)
end
def test_time
cookie = WEBrick::Cooki... | Ruby |
require "webrick"
require "stringio"
require "test/unit"
class TestWEBrickHTTPRequest < Test::Unit::TestCase
def test_simple_request
msg = <<-_end_of_message_
GET /
_end_of_message_
req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP)
req.parse(StringIO.new(msg))
assert(req.meta_vars) # fails if... | Ruby |
require_relative 'base'
class TestMkmf
class TestConvertible < TestMkmf
def test_typeof_builtin
["", ["signed ", ""], "unsigned "].each do |signed, prefix|
%w[short int long].each do |type|
assert_equal((prefix || signed)+type,
mkmf {convertible_int(signed+type)}, M... | Ruby |
require 'test/unit'
require 'mkmf'
require 'tmpdir'
$extout = '$(topdir)/'+RbConfig::CONFIG["EXTOUT"]
RbConfig::CONFIG['topdir'] = CONFIG['topdir'] = File.expand_path(CONFIG['topdir'])
RbConfig::CONFIG["extout"] = CONFIG["extout"] = $extout
$INCFLAGS << " -I."
$extout_prefix = "$(extout)$(target_prefix)/"
class TestM... | Ruby |
require_relative 'base'
class TestMkmf
class TestSignedness < TestMkmf
def test_typeof_builtin
bug4144 = '[ruby-dev:42731]'
[["", "-1"], ["signed ", "-1"], ["unsigned ", "+1"]].each do |signed, expect|
%w[short int long].each do |type|
assert_equal(expect.to_i, mkmf {check_signednes... | Ruby |
require_relative 'base'
class TestMkmf
class TestFindExecutable < TestMkmf
def setup
super
@path, ENV["PATH"] = ENV["PATH"], @tmpdir
end
def teardown
ENV["PATH"] = @path
super
end
def test_find_executable
bug2669 = '[ruby-core:27912]'
name = "foobar#{$$}#{ran... | Ruby |
require_relative 'base'
class TestMkmf
class TestSizeof < TestMkmf
def setup
super
@sizeof_short = config_value("SIZEOF_SHORT").to_i
@sizeof_int = config_value("SIZEOF_INT").to_i
@sizeof_long = config_value("SIZEOF_LONG").to_i
@sizeof_long_long = config_value("SIZEOF_LONG_LONG").to_... | Ruby |
require_relative 'base'
class TestMkmf
class TestFlags < TestMkmf
def test_valid_warnflags
val = $extmk
warnflags = $warnflags
makefile = mkmf do
$extmk = false
self.class::CONFIG['warnflags'] = %w"-Wextra
-Wno-unused-parameter -Wno-parentheses -Wno-long-long
-Wn... | Ruby |
require File.expand_path('../helper', __FILE__)
class TestRakeFileListPathMap < Rake::TestCase
def test_file_list_supports_pathmap
assert_equal ['a', 'b'], FileList['dir/a.rb', 'dir/b.rb'].pathmap("%n")
end
end
| Ruby |
require File.expand_path('../helper', __FILE__)
require 'stringio'
class TestRakeExtension < Rake::TestCase
module Redirect
def error_redirect
old_err = $stderr
result = StringIO.new
$stderr = result
yield
result
ensure
$stderr = old_err
end
end
class Sample
... | Ruby |
require File.expand_path('../helper', __FILE__)
require 'rake/loaders/makefile'
class TestRakeMakefileLoader < Rake::TestCase
include Rake
def test_parse
Dir.chdir @tempdir
open 'sample.mf', 'w' do |io|
io << <<-'SAMPLE_MF'
# Comments
a: a1 a2 a3 a4
b: b1 b2 b3 \
b4 b5 b6\
# Mid: Comment
b7
a ... | Ruby |
require File.expand_path('../helper', __FILE__)
begin
old_stderr = $stderr
dev_null = File.exist?('/dev/null') ? '/dev/null' : 'NUL'
$stderr = open dev_null, 'w'
require 'rake/rdoctask'
ensure
$stderr.close
$stderr = old_stderr
end
class TestRakeRDocTask < Rake::TestCase
include Rake
def setup
sup... | Ruby |
require File.expand_path('../helper', __FILE__)
TESTING_REQUIRE = [ ]
class TestRakeApplicationOptions < Rake::TestCase
def setup
super
clear_argv
Rake::FileUtilsExt.verbose_flag = false
Rake::FileUtilsExt.nowrite_flag = false
TESTING_REQUIRE.clear
end
def teardown
clear_argv
Rake... | Ruby |
require File.expand_path('../helper', __FILE__)
class TestRakeNameSpace < Rake::TestCase
class TM
include Rake::TaskManager
end
def test_namespace_creation
mgr = TM.new
ns = Rake::NameSpace.new(mgr, [])
refute_nil ns
end
def test_namespace_lookup
mgr = TM.new
ns = mgr.in_namespace(... | Ruby |
require File.expand_path('../helper', __FILE__)
class TestRakeInvocationChain < Rake::TestCase
def setup
super
@empty = Rake::InvocationChain::EMPTY
@first_member = "A"
@second_member = "B"
@one = @empty.append(@first_member)
@two = @one.append(@second_member)
end
def test_append
... | Ruby |
require File.expand_path('../helper', __FILE__)
class TestRakeTaskArgumentParsing < Rake::TestCase
def setup
super
@app = Rake::Application.new
end
def test_name_only
name, args = @app.parse_task_string("name")
assert_equal "name", name
assert_equal [], args
end
def test_empty_args
... | Ruby |
require File.expand_path('../helper', __FILE__)
require 'date'
require 'time'
require 'rake/contrib/ftptools'
class FakeDate
def self.today
Date.new(2003,10,3)
end
def self.now
Time.local(2003,10,3,12,00,00)
end
end
class TestRakeFtpFile < Rake::TestCase
def setup
super
Rake::FtpFile.class... | Ruby |
require File.expand_path('../helper', __FILE__)
class TestRakeDsl < Rake::TestCase
def setup
super
Rake::Task.clear
end
def test_namespace_command
namespace "n" do
task "t"
end
refute_nil Rake::Task["n:t"]
end
def test_namespace_command_with_bad_name
ex = assert_raises(Argume... | Ruby |
require File.expand_path('../helper', __FILE__)
require 'rake/clean'
class TestRakeClean < Rake::TestCase
include Rake
def test_clean
load 'rake/clean.rb', true
assert Task['clean'], "Should define clean"
assert Task['clobber'], "Should define clobber"
assert Task['clobber'].prerequisites.include?... | Ruby |
require File.expand_path('../helper', __FILE__)
class TestRakeRakeTestLoader < Rake::TestCase
def test_pattern
orig_LOADED_FEATURES = $:.dup
FileUtils.touch 'foo.rb'
FileUtils.touch 'test_a.rb'
FileUtils.touch 'test_b.rb'
ARGV.replace %w[foo.rb test_*.rb -v]
load File.expand_path('../../..... | Ruby |
require File.expand_path('../helper', __FILE__)
require 'thread'
class TestRakeMultiTask < Rake::TestCase
include Rake
include Rake::DSL
def setup
super
Task.clear
@runs = Array.new
@mutex = Mutex.new
end
def add_run(obj)
@mutex.synchronize do
@runs << obj
end
end
def te... | Ruby |
require File.expand_path('../helper', __FILE__)
require 'fileutils'
class TestRakeTask < Rake::TestCase
include Rake
def setup
super
Task.clear
Rake::TaskManager.record_task_metadata = true
end
def teardown
Rake::TaskManager.record_task_metadata = false
super
end
def test_create
... | Ruby |
require File.expand_path('../helper', __FILE__)
class TestRakePathMapPartial < Rake::TestCase
def test_pathmap_partial
@path = "1/2/file"
def @path.call(n)
pathmap_partial(n)
end
assert_equal("1", @path.call(1))
assert_equal("1/2", @path.call(2))
assert_equal("1/2", @path.call(3))
a... | Ruby |
require File.expand_path('../helper', __FILE__)
class TestRake < Rake::TestCase
def test_each_dir_parent
assert_equal ['a'], alldirs('a')
assert_equal ['a/b', 'a'], alldirs('a/b')
assert_equal ['/a/b', '/a', '/'], alldirs('/a/b')
if File.dirname("c:/foo") == "c:"
# Under Unix
assert_equal... | Ruby |
require File.expand_path('../helper', __FILE__)
class TestRakeWin32 < Rake::TestCase
Win32 = Rake::Win32
def test_win32_system_dir_uses_home_if_defined
ENV['HOME'] = 'C:\\HP'
assert_equal "C:/HP/Rake", Win32.win32_system_dir
end
def test_win32_system_dir_uses_homedrive_homepath_when_no_home_defined... | Ruby |
require File.expand_path('../helper', __FILE__)
######################################################################
class TestRakeTaskArguments < Rake::TestCase
def teardown
ENV.delete('rev')
ENV.delete('VER')
super
end
def test_empty_arg_list_is_empty
ta = Rake::TaskArguments.new([], [])
... | Ruby |
require File.expand_path('../helper', __FILE__)
require 'rake/testtask'
class TestRakeTestTask < Rake::TestCase
include Rake
def test_initialize
tt = Rake::TestTask.new do |t| end
refute_nil tt
assert_equal :test, tt.name
assert_equal ['lib'], tt.libs
assert_equal 'test/test*.rb', tt.pattern
... | Ruby |
require File.expand_path('../helper', __FILE__)
class TestRakeRequire < Rake::TestCase
def test_can_load_rake_library
rakefile_rakelib
app = Rake::Application.new
assert app.instance_eval {
rake_require("test2", ['rakelib'], [])
}
end
def test_wont_reload_rake_library
rakefile_rakeli... | Ruby |
require File.expand_path('../helper', __FILE__)
begin
old_verbose = $VERBOSE
$VERBOSE = nil
require 'rake/contrib/sys'
ensure
$VERBOSE = old_verbose
end
class TestSys < Rake::TestCase
def test_split_all
assert_equal ['a'], Sys.split_all('a')
assert_equal ['..'], Sys.split_all('..')
assert_equal ... | Ruby |
require File.expand_path('../helper', __FILE__)
require 'fileutils'
class TestRakeRules < Rake::TestCase
include Rake
SRCFILE = "abc.c"
SRCFILE2 = "xyz.c"
FTNFILE = "abc.f"
OBJFILE = "abc.o"
FOOFILE = "foo"
DOTFOOFILE = ".foo"
def setup
super
Task.clear
@runs = []
end
... | Ruby |
require File.expand_path('../helper', __FILE__)
class TestRakeApplication < Rake::TestCase
def setup
super
@app = Rake.application
@app.options.rakelib = []
end
def test_constant_warning
_, err = capture_io do @app.instance_eval { const_warning("Task") } end
assert_match(/warning/i, err)
... | Ruby |
require File.expand_path('../helper', __FILE__)
require 'rake/tasklib'
class TestRakeTaskLib < Rake::TestCase
def test_paste
tl = Rake::TaskLib.new
assert_equal :ab, tl.paste(:a, :b)
end
end
| Ruby |
require File.expand_path('../helper', __FILE__)
class TestRakePathMapExplode < Rake::TestCase
def setup
super
String.class_eval { public :pathmap_explode }
end
def teardown
String.class_eval { protected :pathmap_explode }
super
end
def test_explode
assert_equal ['a'], 'a'.pathmap_expl... | Ruby |
require File.expand_path('../helper', __FILE__)
require 'fileutils'
class TestRakeFileTask < Rake::TestCase
include Rake
def setup
super
Task.clear
@runs = Array.new
FileUtils.rm_f NEWFILE
FileUtils.rm_f OLDFILE
end
def test_file_need
name = "dummy"
file name
ftask = Task[na... | Ruby |
require File.expand_path('../helper', __FILE__)
class TestRakeTaskManager < Rake::TestCase
def setup
super
@tm = Rake::TestCase::TaskManager.new
end
def test_create_task_manager
refute_nil @tm
assert_equal [], @tm.tasks
end
def test_define_task
t = @tm.define_task(Rake::Task, :t)
... | Ruby |
module FileCreation
OLDFILE = "old"
NEWFILE = "new"
def create_timed_files(oldfile, *newfiles)
return if (File.exist?(oldfile) &&
newfiles.all? { |newfile|
File.exist?(newfile) && File.stat(newfile).mtime > File.stat(oldfile).mtime
})
now = Time.now
create_file(oldfile, now - 60)... | Ruby |
require File.expand_path('../helper', __FILE__)
class TestRakeEarlyTime < Rake::TestCase
def test_create
early = Rake::EarlyTime.instance
assert early <= Time.now
assert early < Time.now
assert early != Time.now
assert Time.now > early
assert Time.now >= early
assert Time.now != early
e... | Ruby |
require 'rubygems'
begin
gem 'minitest'
rescue Gem::LoadError
end
require 'minitest/autorun'
require 'rake'
require 'tmpdir'
require File.expand_path('../file_creation', __FILE__)
begin
require 'test/ruby/envutil'
rescue LoadError
# for ruby trunk
end
class Rake::TestCase < MiniTest::Unit::TestCase
include ... | Ruby |
require File.expand_path('../helper', __FILE__)
require 'fileutils'
######################################################################
class TestRakeFileCreationTask < Rake::TestCase
include Rake
include Rake::DSL
DUMMY_DIR = 'dummy_dir'
def setup
super
Task.clear
end
def test_file_needed
... | Ruby |
require File.expand_path('../helper', __FILE__)
class TestRakeFileList < Rake::TestCase
FileList = Rake::FileList
def setup
super
FileUtils.mkdir "CVS" rescue nil
FileUtils.mkdir ".svn" rescue nil
@cdir = "cfiles"
FileUtils.mkdir @cdir rescue nil
FileUtils.touch ".dummy"
FileUtils.tou... | Ruby |
require File.expand_path('../helper', __FILE__)
require 'fileutils'
class TestRakeDefinitions < Rake::TestCase
include Rake
EXISTINGFILE = "existing"
def setup
super
Task.clear
end
def test_task
done = false
task :one => [:two] do done = true end
task :two
task :three => [:one, :t... | Ruby |
require File.expand_path('../helper', __FILE__)
require 'fileutils'
require 'open3'
class TestRakeFunctional < Rake::TestCase
def setup
@rake_path = File.expand_path("../../../bin/rake", __FILE__)
lib_path = File.expand_path("../../../lib", __FILE__)
@ruby_options = ["-I#{lib_path}", "-I."]
@verbose... | Ruby |
require File.expand_path('../helper', __FILE__)
class TestRakeTopLevelFunctions < Rake::TestCase
def setup
super
@app = Object.new
def @app.called
@called
end
def @app.method_missing(*a, &b)
@called ||= []
@called << [a, b]
nil
end
Rake.application = @app
en... | Ruby |
require File.expand_path('../helper', __FILE__)
require 'rake/packagetask'
class TestRakePackageTask < Rake::TestCase
def test_initialize
touch 'install.rb'
touch 'a.c'
touch 'b.c'
mkdir 'CVS'
touch 'a.rb~'
pkg = Rake::PackageTask.new("pkgr", "1.2.3") { |p|
p.package_files << "install... | Ruby |
require File.expand_path('../helper', __FILE__)
require 'fileutils'
require 'stringio'
class TestRakeFileUtils < Rake::TestCase
def teardown
FileUtils::LN_SUPPORTED[0] = true
RakeFileUtils.verbose_flag = Rake::FileUtilsExt::DEFAULT
super
end
def test_rm_one_file
create_file("a")
FileUtils.... | Ruby |
require File.expand_path('../helper', __FILE__)
class TestRakePseudoStatus < Rake::TestCase
def test_with_zero_exit_status
s = Rake::PseudoStatus.new
assert_equal 0, s.exitstatus
assert_equal 0, s.to_i
assert_equal 0, s >> 8
refute s.stopped?
assert s.exited?
end
def test_with_99_exit_st... | Ruby |
require File.expand_path('../helper', __FILE__)
class TestRakePathMap < Rake::TestCase
def test_returns_self_with_no_args
assert_equal "abc.rb", "abc.rb".pathmap
end
def test_s_returns_file_separator
sep = File::ALT_SEPARATOR || File::SEPARATOR
assert_equal sep, "abc.rb".pathmap("%s")
assert_eq... | Ruby |
require File.expand_path('../helper', __FILE__)
require 'fileutils'
class TestRakeDirectoryTask < Rake::TestCase
include Rake
def test_directory
desc "DESC"
directory "a/b/c"
assert_equal FileCreationTask, Task["a"].class
assert_equal FileCreationTask, Task["a/b"].class
assert_equal FileCrea... | Ruby |
require File.expand_path('../helper', __FILE__)
class TestRakeTaskManagerArgumentResolution < Rake::TestCase
def setup
super
Rake.application.options.ignore_deprecate = true
end
def teardown
Rake.application.options.ignore_deprecate = false
super
end
def test_good_arg_patterns
assert... | Ruby |
require File.expand_path('../helper', __FILE__)
class TestRakeTaskWithArguments < Rake::TestCase
include Rake
def setup
super
Task.clear
Rake::TaskManager.record_task_metadata = true
end
def teardown
Rake::TaskManager.record_task_metadata = false
super
end
def test_no_args_given
... | Ruby |
require 'test/unit'
require "xmlrpc/create"
require "xmlrpc/parser"
require "xmlrpc/config"
class Test_Features < Test::Unit::TestCase
def setup
@params = [nil, {"test" => nil}, [nil, 1, nil]]
end
def test_nil_create
XMLRPC::XMLWriter.each_installed_writer do |writer|
c = XMLRPC::Create.new(write... | Ruby |
# coding: utf-8
require 'test/unit'
require 'webrick'
require_relative 'webrick_testing'
require "xmlrpc/server"
require 'xmlrpc/client'
require 'logger'
class Test_Webrick < Test::Unit::TestCase
include WEBrick_Testing
@@basic_auth = WEBrick::HTTPAuth::BasicAuth.new(
:Realm => 'auth',
:UserDB => WEBrick... | Ruby |
require 'test/unit'
require 'xmlrpc/datetime'
require "xmlrpc/parser"
require 'yaml'
module GenericParserTest
def datafile(base)
File.join(File.dirname(__FILE__), "data", base)
end
def load_data(name)
[File.read(datafile(name) + ".xml"), YAML.load(File.read(datafile(name) + ".expected"))]
end
def s... | Ruby |
require 'timeout'
module WEBrick_Testing
class DummyLog < WEBrick::BasicLog
def initialize() super(self) end
def <<(*args) end
end
def start_server(config={})
raise "already started" if defined?(@__server) && @__server
@__started = false
@__server_thread = Thread.new {
@__server = WEB... | Ruby |
require 'test/unit'
require "xmlrpc/datetime"
class Test_DateTime < Test::Unit::TestCase
def test_new
dt = createDateTime()
assert_instance_of(XMLRPC::DateTime, dt)
end
def test_new_exception
assert_raise(ArgumentError) { XMLRPC::DateTime.new(4.5, 13, 32, 25, 60, 60) }
assert_raise(ArgumentErr... | Ruby |
require 'test/unit'
require 'time'
require 'webrick'
require_relative 'webrick_testing'
require "xmlrpc/server"
require 'xmlrpc/client'
class TestCookie < Test::Unit::TestCase
include WEBrick_Testing
def create_servlet
s = XMLRPC::WEBrickServlet.new
def s.logged_in_users
@logged_in_users ||= {}
... | Ruby |
require 'test/unit'
require "xmlrpc/marshal"
class Test_Marshal < Test::Unit::TestCase
# for test_parser_values
class Person
include XMLRPC::Marshallable
attr_reader :name
def initialize(name)
@name = name
end
end
def test1_dump_response
assert_nothing_raised(NameError) {
XMLR... | Ruby |
require 'test/unit'
require 'singleton'
class TestSingleton < Test::Unit::TestCase
class SingletonTest
include Singleton
end
def test_marshal
o1 = SingletonTest.instance
m = Marshal.dump(o1)
o2 = Marshal.load(m)
assert_same(o1, o2)
end
def test_instance_never_changes
a = SingletonTe... | Ruby |
require 'test/unit'
require 'yaml'
module Syck
class TestOmap < Test::Unit::TestCase
def test_keys
map = YAML::Omap.new
map['foo'] = 'bar'
assert_equal 'bar', map['foo']
end
def test_order
map = YAML::Omap.new
map['a'] = 'b'
map['b'] = 'c'
assert_equal [%w{a b},... | Ruby |
require 'test/unit'
require 'yaml'
module Syck
class TestClass < Test::Unit::TestCase
def setup
@engine = YAML::ENGINE.yamler
YAML::ENGINE.yamler = 'syck'
end
def teardown
YAML::ENGINE.yamler = @engine
end
def test_to_yaml
assert_raises(::TypeError) do
TestClass.... | Ruby |
require 'test/unit'
require 'yaml'
class StructWithIvar < Struct.new(:foo)
attr_reader :bar
def initialize *args
super
@bar = 'hello'
end
end
module Syck
class TestStruct < MiniTest::Unit::TestCase
def setup
@current_engine = YAML::ENGINE.yamler
YAML::ENGINE.yamler = 'syck'
end... | Ruby |
require 'test/unit'
require 'yaml'
module Syck
class TestArray < Test::Unit::TestCase
def setup
@list = [{ :a => 'b' }, 'foo']
end
def test_to_yaml
assert_equal @list, YAML.load(@list.to_yaml)
end
def test_dump
assert_equal @list, YAML.load(YAML.dump(@list))
end
end
end
| Ruby |
require 'test/unit'
require 'yaml'
module Syck
###
# Test booleans from YAML spec:
# http://yaml.org/type/bool.html
class TestBoolean < Test::Unit::TestCase
%w{ yes Yes YES true True TRUE on On ON }.each do |truth|
define_method(:"test_#{truth}") do
assert_equal true, YAML.load("--- #{truth}"... | Ruby |
require 'test/unit'
require 'yaml'
module Syck
class TestSymbol < Test::Unit::TestCase
def test_to_yaml
assert_equal :a, YAML.load(:a.to_yaml)
end
def test_dump
assert_equal :a, YAML.load(YAML.dump(:a))
end
def test_stringy
assert_equal :"1", YAML.load(YAML.dump(:"1"))
end... | Ruby |
require 'test/unit'
require 'yaml'
module Syck
class TestString < Test::Unit::TestCase
def test_binary_string_null
string = "\x00"
yml = YAML.dump string
assert_match(/binary/, yml)
assert_equal string, YAML.load(yml)
end
def test_binary_string
string = binary_string
... | Ruby |
require 'test/unit'
require 'yaml'
module Syck
class TestString < Test::Unit::TestCase
def test_usec_long
bug4571 = '[ruby-core:35713]'
assert_equal(34, YAML.load("2011-03-22t23:32:11.0000342222+01:00").usec, bug4571)
end
def test_usec_very_long
t = "2011-03-22t23:32:11.0000342"+"0"*10... | Ruby |
require 'test/unit'
require 'yaml'
module Syck
###
# Test null from YAML spec:
# http://yaml.org/type/null.html
class TestNull < Test::Unit::TestCase
def test_null_list
assert_equal [nil] * 5, YAML.load(<<-eoyml)
---
- ~
- null
-
- Null
- NULL
eoyml
end
end
end
| Ruby |
require 'test/unit'
require 'yaml'
module Syck
class TestHash < Test::Unit::TestCase
def setup
@hash = { :a => 'b' }
end
def test_to_yaml
assert_equal @hash, YAML.load(@hash.to_yaml)
end
def test_dump
assert_equal @hash, YAML.load(YAML.dump(@hash))
end
def test_ref_ap... | Ruby |
require 'test/unit'
require 'yaml/store'
Syck::Store = YAML::Store unless defined?(Syck::Store)
module Syck
class YAMLStoreTest < Test::Unit::TestCase
def setup
@engine, YAML::ENGINE.yamler = YAML::ENGINE.yamler, 'syck'
@yamlstore_file = "yamlstore.tmp.#{Process.pid}"
@yamlstore = YAML::Store.n... | Ruby |
require 'test/unit'
require 'yaml'
module Syck
class TestSet < Test::Unit::TestCase
def setup
@set = YAML::Set.new
@set['foo'] = 'bar'
@set['bar'] = 'baz'
end
def test_to_yaml
assert_match(/!set/, @set.to_yaml)
end
def test_roundtrip
assert_equal(@set, YAML.load(YA... | Ruby |
require 'test/unit'
require 'yaml'
| Ruby |
# -*- mode: ruby; ruby-indent-level: 4; tab-width: 4; indent-tabs-mode: t -*-
# vim:sw=4:ts=4
# $Id: test_yaml.rb 31573 2011-05-15 11:55:52Z nobu $
#
require 'test/unit'
require 'yaml'
require 'syck/ypath'
# [ruby-core:01946]
module YAML_Tests
StructTest = Struct::new( :c )
end
module Syck
class YAML_U... | Ruby |
require 'test/unit'
require 'yaml'
module Syck
class TestException < Test::Unit::TestCase
class Wups < Exception
attr_reader :foo, :bar
def initialize *args
super
@foo = 1
@bar = 2
end
end
def setup
@wups = Wups.new('test_message')
end
def test_to... | Ruby |
require 'test/unit'
require 'yaml'
module Syck
class TestYamlProperties < Test::Unit::TestCase
class Foo
attr_reader :a, :b, :c
def initialize
@a = 1
@b = 2
@c = 3
end
def to_yaml_properties
[:@a, :@b]
end
end
def test_object_dump_yaml_prope... | Ruby |
module InlineTest
def eval_part(libname, sep, part)
path = libpath(libname)
program = File.open(path) { |f| f.read }
mainpart, endpart = program.split(sep)
if endpart.nil?
raise RuntimeError.new("No #{part} part in the library '#{path}'")
end
eval(endpart, TOPLEVEL_BINDING, path, mainpar... | Ruby |
begin
require_relative 'helper'
rescue LoadError
end
class TestFiddle < Fiddle::TestCase
def test_constants_match
[
:TYPE_VOID,
:TYPE_VOIDP,
:TYPE_CHAR,
:TYPE_SHORT,
:TYPE_INT,
:TYPE_LONG,
:TYPE_LONG_LONG,
:TYPE_FLOAT,
:TYPE_DOUBLE,
].each do |name|
... | Ruby |
begin
require_relative 'helper'
rescue LoadError
end
module Fiddle
class TestClosure < Fiddle::TestCase
def test_argument_errors
assert_raises(TypeError) do
Closure.new(TYPE_INT, TYPE_INT)
end
assert_raises(TypeError) do
Closure.new('foo', [TYPE_INT])
end
assert_... | Ruby |
require 'minitest/autorun'
require 'dl'
require 'fiddle'
# FIXME: this is stolen from DL and needs to be refactored.
require_relative '../ruby/envutil'
libc_so = libm_so = nil
case RUBY_PLATFORM
when /cygwin/
libc_so = "cygwin1.dll"
libm_so = "cygwin1.dll"
when /x86_64-linux/
libc_so = "/lib64/libc.so.6"
lib... | Ruby |
begin
require_relative 'helper'
rescue LoadError
end
module Fiddle
class TestFunction < Fiddle::TestCase
def setup
super
Fiddle.last_error = nil
end
def test_default_abi
func = Function.new(@libm['sin'], [TYPE_DOUBLE], TYPE_DOUBLE)
assert_equal Function::DEFAULT, func.abi
e... | Ruby |
require 'test/unit'
require 'digest'
require_relative '../with_different_ofs.rb'
class TestDigestExtend < Test::Unit::TestCase
extend DifferentOFS
class MyDigest < Digest::Class
def initialize(*arg)
super
@buf = []
end
def initialize_copy(org)
@buf = org.buf.dup
end
def upd... | Ruby |
require_relative '../inlinetest.rb'
InlineTest.loadtest__END__part('digest/hmac.rb')
| Ruby |
#!/usr/bin/env ruby
#
# $RoughId: test.rb,v 1.4 2001/07/13 15:38:27 knu Exp $
# $Id: test_digest.rb 32547 2011-07-15 03:05:23Z nahi $
require 'test/unit'
require 'digest'
%w[digest/md5 digest/rmd160 digest/sha1 digest/sha2].each do |lib|
begin
require lib
rescue LoadError
end
end
module TestDigest
Data1 ... | Ruby |
require 'test/unit'
require_relative '../ruby/envutil'
module TestIRB
class TestCompletion < Test::Unit::TestCase
def test_nonstring_module_name
begin
require "irb/completion"
bug5938 = '[ruby-core:42244]'
cmds = %W[-rirb -rirb/completion -e IRB.setup(__FILE__)
-e IRB.conf[... | Ruby |
require 'test/unit'
require_relative '../ruby/envutil'
module TestIRB
class TestOption < Test::Unit::TestCase
def test_end_of_option
bug4117 = '[ruby-core:33574]'
status = assert_in_out_err(%w[-rirb -e IRB.start(__FILE__) -- -f --], "", //, [], bug4117)
assert(status.success?, bug4117)
end
... | Ruby |
require 'test/unit'
require 'ostruct'
class TC_OpenStruct < Test::Unit::TestCase
def test_equality
o1 = OpenStruct.new
o2 = OpenStruct.new
assert_equal(o1, o2)
o1.a = 'a'
assert_not_equal(o1, o2)
o2.a = 'a'
assert_equal(o1, o2)
o1.a = 'b'
assert_not_equal(o1, o2)
o2 = Obje... | Ruby |
require 'test/unit'
class TestAssertion < Test::Unit::TestCase
def test_wrong_assertion
error, line = assert_raise(ArgumentError) {assert(true, true)}, __LINE__
assert_match(/assertion message must be String or Proc, but TrueClass was given/, error.message)
assert_match(/\A#{Regexp.quote(__FILE__)}:#{line... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.