Browse files

Make tests pass on 1.8 ☹

  • Loading branch information...
1 parent f18d045 commit 09b16d21d35962c3cc18b19ffd1fb2ef00b66977 @drbrain committed Mar 25, 2011
Showing with 8 additions and 5 deletions.
  1. +2 −1 ext/pasteboard/pasteboard.c
  2. +6 −4 test/test_pasteboard.rb
View
3 ext/pasteboard/pasteboard.c
@@ -447,10 +447,11 @@ Init_pasteboard(void) {
cPB = rb_define_class("Pasteboard", rb_cObject);
cPBType = rb_const_get_at(cPB, rb_intern("Type"));
- cPBTypeEncodings = rb_const_get_at(cPBType, rb_intern("Encodings"));
ePBError = rb_const_get_at(cPB, rb_intern("Error"));
#if HAVE_RB_STR_ENCODE
+ cPBTypeEncodings = rb_const_get_at(cPBType, rb_intern("Encodings"));
+
utf8_encoding = rb_enc_from_encoding(rb_utf8_encoding());
binary_encoding = rb_const_get_at(rb_cEncoding, rb_intern("BINARY"));
utf16be_encoding = rb_const_get_at(rb_cEncoding, rb_intern("UTF_16BE"));
View
10 test/test_pasteboard.rb
@@ -7,6 +7,7 @@ class TestPasteboard < MiniTest::Unit::TestCase
def setup
@pb = Pasteboard.new nil
+ @encoding = defined?(Encoding)
end
def test_initialize
@@ -43,7 +44,8 @@ def test_copy_item_flavors
assert_equal [Pasteboard::Type::PLAIN_TEXT, Pasteboard::Type::UTF_8],
flavors[0, 2]
- assert flavors.all? { |flavor| flavor.encoding == Encoding::UTF_8 }
+ assert flavors.all? { |flavor| flavor.encoding == Encoding::UTF_8 } if
+ @encoding
end
def test_copy_item_flavor_data
@@ -52,12 +54,12 @@ def test_copy_item_flavor_data
data = @pb.copy_item_flavor_data 0, Pasteboard::Type::PLAIN_TEXT
assert_equal 'pi', data
- assert_equal Encoding::BINARY, data.encoding
+ assert_equal Encoding::BINARY, data.encoding if @encoding
data = @pb.copy_item_flavor_data 0, Pasteboard::Type::UTF_8
assert_equal 'π', data
- assert_equal Encoding::UTF_8, data.encoding
+ assert_equal Encoding::UTF_8, data.encoding if @encoding
end
def test_get_item_count
@@ -91,7 +93,7 @@ def test_put_item_flavor
data = @pb.copy_item_flavor_data 5, 'flavor'
assert_equal 'data', data
- assert_equal Encoding::BINARY, data.encoding
+ assert_equal Encoding::BINARY, data.encoding if @encoding
end
def test_sync

0 comments on commit 09b16d2

Please sign in to comment.