Permalink
Browse files

Specs for C-API rb_rs, rb_default_rs.

  • Loading branch information...
1 parent 52cb119 commit b8a4b816d341396fbd6b67a350489bb5a94d2555 @brixen brixen committed Apr 27, 2012
@@ -67,6 +67,18 @@ static VALUE global_spec_rb_set_kcode(VALUE self, VALUE code) {
}
#endif
+#ifdef HAVE_RB_RS
+static VALUE global_spec_rb_rs(VALUE self) {
+ return rb_rs;
+}
+#endif
+
+#ifdef HAVE_RB_DEFAULT_RS
+static VALUE global_spec_rb_default_rs(VALUE self) {
+ return rb_default_rs;
+}
+#endif
+
void Init_globals_spec() {
VALUE cls;
cls = rb_define_class("CApiGlobalSpecs", rb_cObject);
@@ -99,6 +111,14 @@ void Init_globals_spec() {
#ifdef HAVE_RB_SET_KCODE
rb_define_method(cls, "rb_set_kcode", global_spec_rb_set_kcode, 1);
#endif
+
+#ifdef HAVE_RB_RS
+ rb_define_method(cls, "rb_rs", global_spec_rb_rs, 0);
+#endif
+
+#ifdef HAVE_RB_DEFAULT_RS
+ rb_define_method(cls, "rb_default_rs", global_spec_rb_default_rs, 0);
+#endif
}
#ifdef __cplusplus
@@ -237,12 +237,14 @@
#define HAVE_RFLOAT_VALUE 1
/* Globals */
+#define HAVE_RB_DEFAULT_RS 1
#define HAVE_RB_DEFINE_HOOKED_VARIABLE 1
#define HAVE_RB_DEFINE_READONLY_VARIABLE 1
#define HAVE_RB_DEFINE_VARIABLE 1
#define HAVE_RB_F_GLOBAL_VARIABLES 1
#define HAVE_RB_GV_GET 1
#define HAVE_RB_GV_SET 1
+#define HAVE_RB_RS 1
#define HAVE_RB_SET_KCODE 1
/* Hash */
@@ -68,4 +68,29 @@
end
end
end
+
+ describe "rb_rs" do
+ before :each do
+ @dollar_slash = $/
+ end
+
+ after :each do
+ $/ = @dollar_slash
+ end
+
+ it "returns \\n by default" do
+ @f.rb_rs.should == "\n"
+ end
+
+ it "returns the value of $/" do
+ $/ = "foo"
+ @f.rb_rs.should == "foo"
+ end
+ end
+
+ describe "rb_default_rs" do
+ it "returns \\n" do
+ @f.rb_default_rs.should == "\n"
+ end
+ end
end

0 comments on commit b8a4b81

Please sign in to comment.