summaryrefslogtreecommitdiff
path: root/ext/syslog
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-11-27 08:36:22 (GMT)
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-11-27 08:36:22 (GMT)
commitad42685bf4e2e5f1062c2f42b23a6c96566b56f8 (patch)
tree0e7a355ca21796b1490a8293b420c1b03bacbbd0 /ext/syslog
parentce0fd8c52311fef0a95ce9d3d72c756ca6f5b742 (diff)
* ext/syslog/test.rb: Syslog.close should raise RuntimeError when
not opened. * ext/syslog/test.rb: Syslog.{ident,options,facility,mask} should all return nil when not opened. * ext/syslog/test.rb: Change back the output format of inspect(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/syslog')
-rw-r--r--ext/syslog/test.rb27
1 files changed, 18 insertions, 9 deletions
diff --git a/ext/syslog/test.rb b/ext/syslog/test.rb
index ed5dd9d..cfa33ef 100644
--- a/ext/syslog/test.rb
+++ b/ext/syslog/test.rb
@@ -28,7 +28,7 @@ class TestSyslog < Test::Unit::TestCase
assert_equal(Syslog, sl2)
assert_equal(Syslog, sl3)
ensure
- Syslog.close
+ Syslog.close if Syslog.opened?
end
def test_open
@@ -59,16 +59,16 @@ class TestSyslog < Test::Unit::TestCase
Syslog.open
Syslog.close
- assert_equal($0, Syslog.ident)
- assert_equal(Syslog::LOG_PID | Syslog::LOG_CONS, Syslog.options)
- assert_equal(Syslog::LOG_USER, Syslog.facility)
+ assert_equal(nil, Syslog.ident)
+ assert_equal(nil, Syslog.options)
+ assert_equal(nil, Syslog.facility)
# block
param = nil
Syslog.open { |param| }
assert_equal(Syslog, param)
ensure
- Syslog.close
+ Syslog.close if Syslog.opened?
end
def test_opened?
@@ -87,7 +87,15 @@ class TestSyslog < Test::Unit::TestCase
assert_equal(false, Syslog.opened?)
end
+ def test_close
+ assert_raises(RuntimeError) {
+ Syslog.close
+ }
+ end
+
def test_mask
+ assert_equal(nil, Syslog.mask)
+
Syslog.open
orig = Syslog.mask
@@ -100,7 +108,7 @@ class TestSyslog < Test::Unit::TestCase
Syslog.mask = orig
ensure
- Syslog.close
+ Syslog.close if Syslog.opened?
end
def test_log
@@ -142,14 +150,15 @@ class TestSyslog < Test::Unit::TestCase
def test_inspect
Syslog.open { |sl|
- assert_equal(format('<#%s: ident="%s", options=%d, facility=%d, mask=%d%s>',
+ assert_equal(format('<#%s: opened=true, ident="%s", options=%d, facility=%d, mask=%d>',
Syslog,
sl.ident,
sl.options,
sl.facility,
- sl.mask,
- sl.opened? ? ', opened' : ''),
+ sl.mask),
sl.inspect)
}
+
+ assert_equal(format('<#%s: opened=false>', Syslog), Syslog.inspect)
end
end