1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

This commit was manufactured by cvs2svn to create branch 'ruby_1_8'.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
(no author) 2004-12-03 18:36:23 +00:00
parent ced3d3c870
commit 61ab3618f3
7 changed files with 424 additions and 0 deletions

View file

@ -0,0 +1,73 @@
begin
require "readline"
rescue LoadError
end
if defined?(Readline)
require "test/unit"
require "tempfile"
class TestReadline < Test::Unit::TestCase
def test_readline
stdin = Tempfile.new("test_readline_stdin")
stdout = Tempfile.new("test_readline_stdout")
begin
stdin.write("hello\n")
stdin.close
stdout.close
line = replace_stdio(stdin.path, stdout.path) { Readline.readline("> ") }
assert_equal("hello", line)
assert_equal(true, line.tainted?)
stdout.open
assert_equal("> ", stdout.read(2))
assert_raises(SecurityError) do
Thread.start {
$SAFE = 1
replace_stdio(stdin.path, stdout.path) do
Readline.readline("> ".taint)
end
}.join
end
assert_raises(SecurityError) do
Thread.start {
$SAFE = 4
replace_stdio(stdin.path, stdout.path) { Readline.readline("> ") }
}.join
end
ensure
stdin.close(true)
stdout.close(true)
end
end
def test_completion_append_character
Readline.completion_append_character = "x"
assert_equal("x", Readline.completion_append_character)
Readline.completion_append_character = "xyz"
assert_equal("x", Readline.completion_append_character)
Readline.completion_append_character = nil
assert_equal(nil, Readline.completion_append_character)
Readline.completion_append_character = ""
assert_equal(nil, Readline.completion_append_character)
end
private
def replace_stdio(stdin_path, stdout_path)
orig_stdin = STDIN.dup
orig_stdout = STDOUT.dup
STDIN.reopen(stdin_path, "r")
STDOUT.reopen(stdout_path, "w")
begin
yield
ensure
STDIN.reopen(orig_stdin)
STDOUT.reopen(orig_stdout)
orig_stdin.close
orig_stdout.close
end
end
end
end

View file

@ -0,0 +1,3 @@
---
- true
- false

View file

@ -0,0 +1,3 @@
---
- true
- test

View file

@ -0,0 +1,10 @@
---
- true
- >
Site,SANs,Array
Configured Capacity,Array Reserved Capacity,Array Ava
ilable Capacity,Array % Reserved,Host Allocated,Host Used,Host Free,Host %
Used

View file

@ -0,0 +1,7 @@
---
- Test
-
- Hallo Leute
- " Hallo "
- ''
- " "

View file

@ -0,0 +1,243 @@
---
- true
-
-
subscriber: MegaCorp
lastName: Baker
telephone1: 1-508-791-1267
telephone2: 1-800-445-2588
password: p1111
OID: "1"
email: hbaker@yahoo.com
adminId: hbaker
objectName: AdministratorDO
-
subscriber: CornerStore
lastName: Dragon
telephone1: 1-781-789-9089
telephone2: 1-800-445-2588
password: p3333
OID: "3"
email: adragon@yahoo.com
adminId: adragon
objectName: AdministratorDO
-
subscriber: Cyberdyne
lastName: Rodman
telephone1: 1-617-789-1890
telephone2: 1-800-445-2588
password: p4444
OID: "4"
email: mrodman@yahoo.com
adminId: mrodman
objectName: AdministratorDO
-
subscriber: StarSports
lastName: Jordan
telephone1: 1-617-890-7897
telephone2: 1-800-445-2588
password: p5555
OID: "5"
email: mjordan@yahoo.com
adminId: mjordan
objectName: AdministratorDO
-
subscriber: GreatBooks
lastName: Pippen
telephone1: 1-781-789-9876
telephone2: 1-800-445-2588
password: p6666
OID: "6"
email: gpippen@yahoo.com
adminId: gpippen
objectName: AdministratorDO
-
subscriber: AxisChemicals
lastName: Andhrew
telephone1: 1-781-678-8970
telephone2: 1-800-445-2588
password: p7777
OID: "7"
email: aandrew@yahoo.com
adminId: aandrew
objectName: AdministratorDO
-
subscriber: MediaShop
lastName: Vincent
telephone1: 1-786-897-8908
telephone2: 1-800-445-2588
password: p8888
OID: "8"
email: tvincent@yahoo.com
adminId: tvincent
objectName: AdministratorDO
-
subscriber: SmartShop
lastName: Richard
telephone1: 1-508-789-6789
telephone2: 1-800-445-2588
password: p9999
OID: "9"
email: krichard@yahoo.com
adminId: krichard
objectName: AdministratorDO
-
subscriber: HomeNeeds
lastName: Cornell
telephone1: 1-617-789-8979
telephone2: 1-800-445-2588
password: paaaa
OID: "10"
email: gconell@yahoo.com
adminId: gcornell
objectName: AdministratorDO
-
subscriber: MegaCorp
lastName: HorstMann
telephone1: 1-508-791-1267
telephone2: 1-800-445-2588
password: p1111
OID: "11"
email: shorstmann@yahoo.com
adminId: shorstmann
objectName: AdministratorDO
-
subscriber: CornerStore
lastName: Bob
telephone1: 1-781-789-9089
telephone2: 1-800-445-2588
password: p3333
OID: "13"
email: rbob@yahoo.com
adminId: rbob
objectName: AdministratorDO
-
subscriber: Cyberdyne
lastName: Peter
telephone1: 1-617-789-1890
telephone2: 1-800-445-2588
password: p4444
OID: "14"
email: speter@yahoo.com
adminId: speter
objectName: AdministratorDO
-
subscriber: StarSports
lastName: Novak
telephone1: 1-617-890-7897
telephone2: 1-800-445-2588
password: p5555
OID: "15"
email: pnovak@yahoo.com
adminId: pnovak
objectName: AdministratorDO
-
subscriber: GreatBooks
lastName: Nancy
telephone1: 1-781-789-9876
telephone2: 1-800-445-2588
password: p6666
OID: "16"
email: pnancy@yahoo.com
adminId: pnancy
objectName: AdministratorDO
-
subscriber: AxisChemicals
lastName: Michel
telephone1: 1-781-678-8970
telephone2: 1-800-445-2588
password: p7777
OID: "17"
email: hmichel@yahoo.com
adminId: hmichel
objectName: AdministratorDO
-
subscriber: MediaShop
lastName: David
telephone1: 1-786-897-8908
telephone2: 1-800-445-2588
password: p8888
OID: "18"
email: kdavid@yahoo.com
adminId: kdavid
objectName: AdministratorDO
-
subscriber: SmartShop
lastName: Valnoor
telephone1: 1-508-789-6789
telephone2: 1-800-445-2588
password: p9999
OID: "19"
email: pvalnoor@yahoo.com
adminId: pvalnoor
objectName: AdministratorDO
-
subscriber: HomeNeeds
lastName: Smith
telephone1: 1-617-789-8979
telephone2: 1-800-445-2588
password: paaaa
OID: "20"
email: wsmith@yahoo.com
adminId: wsmith
objectName: AdministratorDO
-
subscriber: MegaCorp
lastName: Caral
telephone1: 1-781-789-9876
telephone2: 1-800-445-2588
password: p6666
OID: "21"
email: gcaral@yahoo.com
adminId: gcaral
objectName: AdministratorDO
-
subscriber: CornerStore
lastName: Hillary
telephone1: 1-786-897-8908
telephone2: 1-800-445-2588
password: p8888
OID: "23"
email: phillary@yahoo.com
adminId: phillary
objectName: AdministratorDO
-
subscriber: Cyberdyne
lastName: Philip
telephone1: 1-508-789-6789
telephone2: 1-800-445-2588
password: p9999
OID: "24"
email: bphilip@yahoo.com
adminId: bphilip
objectName: AdministratorDO
-
subscriber: StarSports
lastName: Andrea
telephone1: 1-617-789-8979
telephone2: 1-800-445-2588
password: paaaa
OID: "25"
email: sandrea@yahoo.com
adminId: sandrea
objectName: AdministratorDO
-
subscriber: s4
lastName: "null"
telephone1: "null"
telephone2: "null"
password: s4
OID: "26"
email: "null"
adminId: s4
objectName: AdministratorDO
-
subscriber: BigBank
lastName: administrator
telephone1: ''
telephone2: ''
password: admin
OID: "82"
email: ''
adminId: admin
objectName: AdministratorDO

View file

@ -0,0 +1,85 @@
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 setup
@xml1, @expected1 = load_data('xml1')
@xml2, @expected2 = load_data('bug_covert')
@xml3, @expected3 = load_data('bug_bool')
@xml4, @expected4 = load_data('value')
@cdata_xml, @cdata_expected = load_data('bug_cdata')
@datetime_xml = File.read(datafile('datetime_iso8601.xml'))
@datetime_expected = XMLRPC::DateTime.new(2004, 11, 5, 1, 15, 23)
@fault_doc = File.read(datafile('fault.xml'))
end
# test parseMethodResponse --------------------------------------------------
def test_parseMethodResponse1
assert_equal(@expected1, @p.parseMethodResponse(@xml1))
end
def test_parseMethodResponse2
assert_equal(@expected2, @p.parseMethodResponse(@xml2))
end
def test_parseMethodResponse3
assert_equal(@expected3, @p.parseMethodResponse(@xml3))
end
def test_cdata
assert_equal(@cdata_expected, @p.parseMethodResponse(@cdata_xml))
end
def test_dateTime
assert_equal(@datetime_expected, @p.parseMethodResponse(@datetime_xml)[1])
end
# test parseMethodCall ------------------------------------------------------
def test_parseMethodCall
assert_equal(@expected4, @p.parseMethodCall(@xml4))
end
# test fault ----------------------------------------------------------------
def test_fault
flag, fault = @p.parseMethodResponse(@fault_doc)
assert_equal(flag, false)
unless fault.is_a? XMLRPC::FaultException
assert(false, "must be an instance of class XMLRPC::FaultException")
end
assert_equal(fault.faultCode, 4)
assert_equal(fault.faultString, "an error message")
end
end
# create test class for each installed parser
XMLRPC::XMLParser.each_installed_parser do |parser|
klass = parser.class
name = klass.to_s.split("::").last
eval %{
class Test_#{name} < Test::Unit::TestCase
include GenericParserTest
def setup
super
@p = #{klass}.new
end
end
}
end