diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-14 15:56:33 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-14 15:56:33 +0000 |
commit | 6479a0163aa798ae379962c6b52f6410b11995cc (patch) | |
tree | 2a63962dc9a2f66cbb4804b4d2bc4680ed00ab3b /spec/rubyspec/optional/capi | |
parent | 938465beb05d481b424e9b06a19124c22a881ee0 (diff) | |
download | ruby-6479a0163aa798ae379962c6b52f6410b11995cc.tar.gz |
Update to ruby/spec@a4bc1d8
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/rubyspec/optional/capi')
-rw-r--r-- | spec/rubyspec/optional/capi/ext/fixnum_spec.c | 20 | ||||
-rw-r--r-- | spec/rubyspec/optional/capi/ext/gc_spec.c | 11 | ||||
-rw-r--r-- | spec/rubyspec/optional/capi/ext/hash_spec.c | 10 | ||||
-rw-r--r-- | spec/rubyspec/optional/capi/ext/proc_spec.c | 20 | ||||
-rw-r--r-- | spec/rubyspec/optional/capi/ext/range_spec.c | 19 | ||||
-rw-r--r-- | spec/rubyspec/optional/capi/ext/rubyspec.h | 10 | ||||
-rw-r--r-- | spec/rubyspec/optional/capi/ext/st_spec.c | 82 | ||||
-rw-r--r-- | spec/rubyspec/optional/capi/ext/string_spec.c | 20 | ||||
-rw-r--r-- | spec/rubyspec/optional/capi/fixnum_spec.rb | 52 | ||||
-rw-r--r-- | spec/rubyspec/optional/capi/gc_spec.rb | 10 | ||||
-rw-r--r-- | spec/rubyspec/optional/capi/hash_spec.rb | 19 | ||||
-rw-r--r-- | spec/rubyspec/optional/capi/proc_spec.rb | 14 | ||||
-rw-r--r-- | spec/rubyspec/optional/capi/range_spec.rb | 27 | ||||
-rw-r--r-- | spec/rubyspec/optional/capi/st_spec.rb | 41 | ||||
-rw-r--r-- | spec/rubyspec/optional/capi/string_spec.rb | 16 |
15 files changed, 367 insertions, 4 deletions
diff --git a/spec/rubyspec/optional/capi/ext/fixnum_spec.c b/spec/rubyspec/optional/capi/ext/fixnum_spec.c index 49dd039c52..78d452f936 100644 --- a/spec/rubyspec/optional/capi/ext/fixnum_spec.c +++ b/spec/rubyspec/optional/capi/ext/fixnum_spec.c @@ -5,23 +5,37 @@ extern "C" { #endif +static VALUE fixnum_spec_FIX2INT(VALUE self, VALUE value) { + int i = FIX2INT(value); + return INT2NUM(i); +} + +static VALUE fixnum_spec_FIX2UINT(VALUE self, VALUE value) { + unsigned int i = FIX2UINT(value); + return UINT2NUM(i); +} + #ifdef HAVE_RB_FIX2UINT static VALUE fixnum_spec_rb_fix2uint(VALUE self, VALUE value) { - return INT2FIX(rb_fix2uint(value)); + unsigned int i = rb_fix2uint(value); + return UINT2NUM(i); } #endif #ifdef HAVE_RB_FIX2INT static VALUE fixnum_spec_rb_fix2int(VALUE self, VALUE value) { - return INT2FIX(rb_fix2int(value)); + int i = rb_fix2int(value); + return INT2NUM(i); } #endif - void Init_fixnum_spec(void) { VALUE cls; cls = rb_define_class("CApiFixnumSpecs", rb_cObject); + rb_define_method(cls, "FIX2INT", fixnum_spec_FIX2INT, 1); + rb_define_method(cls, "FIX2UINT", fixnum_spec_FIX2UINT, 1); + #ifdef HAVE_RB_FIX2UINT rb_define_method(cls, "rb_fix2uint", fixnum_spec_rb_fix2uint, 1); #endif diff --git a/spec/rubyspec/optional/capi/ext/gc_spec.c b/spec/rubyspec/optional/capi/ext/gc_spec.c index c5895eb0aa..05341bb01d 100644 --- a/spec/rubyspec/optional/capi/ext/gc_spec.c +++ b/spec/rubyspec/optional/capi/ext/gc_spec.c @@ -30,6 +30,13 @@ static VALUE gc_spec_rb_gc_disable() { } #endif +#ifdef HAVE_RB_GC +static VALUE gc_spec_rb_gc() { + rb_gc(); + return Qnil; +} +#endif + void Init_gc_spec(void) { VALUE cls; @@ -54,6 +61,10 @@ void Init_gc_spec(void) { rb_define_method(cls, "rb_gc_disable", gc_spec_rb_gc_disable, 0); #endif +#ifdef HAVE_RB_GC + rb_define_method(cls, "rb_gc", gc_spec_rb_gc, 0); +#endif + } #ifdef __cplusplus diff --git a/spec/rubyspec/optional/capi/ext/hash_spec.c b/spec/rubyspec/optional/capi/ext/hash_spec.c index ac45003844..73e7ef5c13 100644 --- a/spec/rubyspec/optional/capi/ext/hash_spec.c +++ b/spec/rubyspec/optional/capi/ext/hash_spec.c @@ -23,6 +23,12 @@ VALUE hash_spec_rb_hash_dup(VALUE self, VALUE hash) { } #endif +#ifdef HAVE_RB_HASH_FETCH +VALUE hash_spec_rb_hash_fetch(VALUE self, VALUE hash, VALUE key) { + return rb_hash_fetch(hash, key); +} +#endif + #ifdef HAVE_RB_HASH_FREEZE VALUE hash_spec_rb_hash_freeze(VALUE self, VALUE hash) { return rb_hash_freeze(hash); @@ -175,6 +181,10 @@ void Init_hash_spec(void) { rb_define_method(cls, "rb_hash_delete_if", hash_spec_rb_hash_delete_if, 1); #endif +#ifdef HAVE_RB_HASH_FETCH + rb_define_method(cls, "rb_hash_fetch", hash_spec_rb_hash_fetch, 2); +#endif + #ifdef HAVE_RB_HASH_FOREACH rb_define_method(cls, "rb_hash_foreach", hash_spec_rb_hash_foreach, 1); rb_define_method(cls, "rb_hash_foreach_stop", hash_spec_rb_hash_foreach_stop, 1); diff --git a/spec/rubyspec/optional/capi/ext/proc_spec.c b/spec/rubyspec/optional/capi/ext/proc_spec.c index b7a47536d9..f9c0f6b1b9 100644 --- a/spec/rubyspec/optional/capi/ext/proc_spec.c +++ b/spec/rubyspec/optional/capi/ext/proc_spec.c @@ -17,6 +17,18 @@ VALUE proc_spec_rb_proc_new(VALUE self) { } #endif +#ifdef HAVE_RB_PROC_ARITY +VALUE proc_spec_rb_proc_arity(VALUE self, VALUE prc) { + return INT2FIX(rb_proc_arity(prc)); +} +#endif + +#ifdef HAVE_RB_PROC_CALL +VALUE proc_spec_rb_proc_call(VALUE self, VALUE prc, VALUE args) { + return rb_proc_call(prc, args); +} +#endif + /* This helper is not strictly necessary but reflects the code in wxRuby that * originally exposed issues with this Proc.new behavior. */ @@ -57,6 +69,14 @@ void Init_proc_spec(void) { rb_define_method(cls, "rb_proc_new", proc_spec_rb_proc_new, 0); #endif +#ifdef HAVE_RB_PROC_ARITY + rb_define_method(cls, "rb_proc_arity", proc_spec_rb_proc_arity, 1); +#endif + +#ifdef HAVE_RB_PROC_CALL + rb_define_method(cls, "rb_proc_call", proc_spec_rb_proc_call, 2); +#endif + rb_define_method(cls, "rb_Proc_new", proc_spec_rb_Proc_new, 1); } diff --git a/spec/rubyspec/optional/capi/ext/range_spec.c b/spec/rubyspec/optional/capi/ext/range_spec.c index 02aff5a5c2..46ee88a85d 100644 --- a/spec/rubyspec/optional/capi/ext/range_spec.c +++ b/spec/rubyspec/optional/capi/ext/range_spec.c @@ -29,6 +29,21 @@ VALUE range_spec_rb_range_values(VALUE self, VALUE range) { } #endif +#ifdef HAVE_RB_RANGE_BEG_LEN +VALUE range_spec_rb_range_beg_len(VALUE self, VALUE range, VALUE begpv, VALUE lenpv, VALUE lenv, VALUE errv) { + long begp = FIX2LONG(begpv); + long lenp = FIX2LONG(lenpv); + long len = FIX2LONG(lenv); + long err = FIX2LONG(errv); + VALUE ary = rb_ary_new(); + VALUE res = rb_range_beg_len(range, &begp, &lenp, len, err); + rb_ary_store(ary, 0, LONG2FIX(begp)); + rb_ary_store(ary, 1, LONG2FIX(lenp)); + rb_ary_store(ary, 2, res); + return ary; +} +#endif + void Init_range_spec(void) { VALUE cls; cls = rb_define_class("CApiRangeSpecs", rb_cObject); @@ -40,6 +55,10 @@ void Init_range_spec(void) { #ifdef HAVE_RB_RANGE_VALUES rb_define_method(cls, "rb_range_values", range_spec_rb_range_values, 1); #endif + +#ifdef HAVE_RB_RANGE_BEG_LEN + rb_define_method(cls, "rb_range_beg_len", range_spec_rb_range_beg_len, 5); +#endif } #ifdef __cplusplus diff --git a/spec/rubyspec/optional/capi/ext/rubyspec.h b/spec/rubyspec/optional/capi/ext/rubyspec.h index 9cba34b888..8866e39af4 100644 --- a/spec/rubyspec/optional/capi/ext/rubyspec.h +++ b/spec/rubyspec/optional/capi/ext/rubyspec.h @@ -299,6 +299,7 @@ #define HAVE_RB_HASH_CLEAR 1 #define HAVE_RB_HASH_DELETE 1 #define HAVE_RB_HASH_DELETE_IF 1 +#define HAVE_RB_HASH_FETCH 1 #define HAVE_RB_HASH_FOREACH 1 #define HAVE_RB_HASH_LOOKUP 1 #define HAVE_RB_HASH_LOOKUP2 1 @@ -372,6 +373,7 @@ #define HAVE_RB_GC_REGISTER_ADDRESS 1 #define HAVE_RB_GC_ENABLE 1 #define HAVE_RB_GC_DISABLE 1 +#define HAVE_RB_GC 1 /* Marshal */ #define HAVE_RB_MARSHAL_DUMP 1 @@ -476,10 +478,13 @@ /* Proc */ #define HAVE_RB_PROC_NEW 1 +#define HAVE_RB_PROC_ARITY 1 +#define HAVE_RB_PROC_CALL 1 /* Range */ #define HAVE_RB_RANGE_NEW 1 #define HAVE_RB_RANGE_VALUES 1 +#define HAVE_RB_RANGE_BEG_LEN 1 /* Rational */ #define HAVE_RB_RATIONAL 1 @@ -499,6 +504,9 @@ #define HAVE_RB_REG_OPTIONS 1 #define HAVE_RB_REG_REGCOMP 1 +/* st */ +#define HAVE_RB_ST 1 + /* String */ #define HAVE_RB_CSTR2INUM 1 #define HAVE_RB_CSTR_TO_INUM 1 @@ -522,6 +530,8 @@ #define HAVE_RB_STR_NEW3 1 #define HAVE_RB_STR_NEW4 1 #define HAVE_RB_STR_NEW5 1 +#define HAVE_RB_TAINTED_STR_NEW 1 +#define HAVE_RB_TAINTED_STR_NEW2 1 #define HAVE_RB_STR_PLUS 1 #define HAVE_RB_STR_TIMES 1 #define HAVE_RB_STR_RESIZE 1 diff --git a/spec/rubyspec/optional/capi/ext/st_spec.c b/spec/rubyspec/optional/capi/ext/st_spec.c new file mode 100644 index 0000000000..ea2d81964d --- /dev/null +++ b/spec/rubyspec/optional/capi/ext/st_spec.c @@ -0,0 +1,82 @@ +#include "ruby.h" +#include "rubyspec.h" + +#include <string.h> +#include <stdarg.h> + +#ifdef HAVE_RB_ST +#include <ruby/st.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef HAVE_RB_ST +VALUE st_spec_st_init_numtable(VALUE self) { + st_table *tbl = st_init_numtable(); + int entries = tbl->num_entries; + st_free_table(tbl); + return INT2FIX(entries); +} + +VALUE st_spec_st_init_numtable_with_size(VALUE self) { + st_table *tbl = st_init_numtable_with_size(128); + int entries = tbl->num_entries; + st_free_table(tbl); + return INT2FIX(entries); +} + +VALUE st_spec_st_insert(VALUE self) { + int entries; + st_table *tbl = st_init_numtable_with_size(128); + st_insert(tbl, 1, 1); + entries = tbl->num_entries; + st_free_table(tbl); + return INT2FIX(entries); +} + +static int sum(st_data_t key, st_data_t value, st_data_t arg) { + *(int*)arg += value; + return ST_CONTINUE; +} + +VALUE st_spec_st_foreach(VALUE self) { + int total = 0; + st_table *tbl = st_init_numtable_with_size(128); + st_insert(tbl, 1, 3); + st_insert(tbl, 2, 4); + st_foreach(tbl, sum, (st_data_t)&total); + st_free_table(tbl); + return INT2FIX(total); +} + +VALUE st_spec_st_lookup(VALUE self) { + st_data_t result = (st_data_t)0; + st_table *tbl = st_init_numtable_with_size(128); + st_insert(tbl, 7, 42); + st_insert(tbl, 2, 4); + st_lookup(tbl, (st_data_t)7, &result); + st_free_table(tbl); + return INT2FIX(result); +} + +#endif + +void Init_st_spec(void) { + VALUE cls; + cls = rb_define_class("CApiStSpecs", rb_cObject); + +#ifdef HAVE_RB_ST + rb_define_method(cls, "st_init_numtable", st_spec_st_init_numtable, 0); + rb_define_method(cls, "st_init_numtable_with_size", st_spec_st_init_numtable_with_size, 0); + rb_define_method(cls, "st_insert", st_spec_st_insert, 0); + rb_define_method(cls, "st_foreach", st_spec_st_foreach, 0); + rb_define_method(cls, "st_lookup", st_spec_st_lookup, 0); +#endif + +} + +#ifdef __cplusplus +} +#endif diff --git a/spec/rubyspec/optional/capi/ext/string_spec.c b/spec/rubyspec/optional/capi/ext/string_spec.c index 69e66fbde1..0568b42212 100644 --- a/spec/rubyspec/optional/capi/ext/string_spec.c +++ b/spec/rubyspec/optional/capi/ext/string_spec.c @@ -257,6 +257,18 @@ VALUE string_spec_rb_str_new5(VALUE self, VALUE str, VALUE ptr, VALUE len) { } #endif +#ifdef HAVE_RB_TAINTED_STR_NEW +VALUE string_spec_rb_tainted_str_new(VALUE self, VALUE str, VALUE len) { + return rb_tainted_str_new(RSTRING_PTR(str), FIX2INT(len)); +} +#endif + +#ifdef HAVE_RB_TAINTED_STR_NEW2 +VALUE string_spec_rb_tainted_str_new2(VALUE self, VALUE str) { + return rb_tainted_str_new2(RSTRING_PTR(str)); +} +#endif + #ifdef HAVE_RB_STR_PLUS VALUE string_spec_rb_str_plus(VALUE self, VALUE str1, VALUE str2) { return rb_str_plus(str1, str2); @@ -564,6 +576,14 @@ void Init_string_spec(void) { rb_define_method(cls, "rb_str_new5", string_spec_rb_str_new5, 3); #endif +#ifdef HAVE_RB_TAINTED_STR_NEW + rb_define_method(cls, "rb_tainted_str_new", string_spec_rb_tainted_str_new, 2); +#endif + +#ifdef HAVE_RB_TAINTED_STR_NEW2 + rb_define_method(cls, "rb_tainted_str_new2", string_spec_rb_tainted_str_new2, 1); +#endif + #ifdef HAVE_RB_STR_PLUS rb_define_method(cls, "rb_str_plus", string_spec_rb_str_plus, 2); #endif diff --git a/spec/rubyspec/optional/capi/fixnum_spec.rb b/spec/rubyspec/optional/capi/fixnum_spec.rb index 87f257fec7..d9e9d1946d 100644 --- a/spec/rubyspec/optional/capi/fixnum_spec.rb +++ b/spec/rubyspec/optional/capi/fixnum_spec.rb @@ -7,6 +7,40 @@ describe "CApiFixnumSpecs" do @s = CApiFixnumSpecs.new end + describe "FIX2INT" do + it "converts a Fixnum to a native int" do + @s.FIX2INT(42).should == 42 + @s.FIX2INT(-14).should == -14 + end + + max_int = (1 << 31) - 1 + min_int = -(1 << 31) + + guard -> { fixnum_min <= min_int and max_int <= fixnum_max } do + it "converts a Fixnum representing the minimum and maximum native int" do + @s.FIX2INT(max_int).should == max_int + @s.FIX2INT(min_int).should == min_int + end + end + + end + + describe "FIX2UINT" do + it "converts a Fixnum to a native int" do + @s.FIX2UINT(42).should == 42 + @s.FIX2UINT(0).should == 0 + end + + max_uint = (1 << 32) - 1 + + guard -> { max_uint <= fixnum_max } do + it "converts a Fixnum representing the maximum native uint" do + @s.FIX2UINT(max_uint).should == max_uint + end + end + + end + platform_is wordsize: 64 do describe "rb_fix2uint" do it "raises a TypeError if passed nil" do @@ -14,6 +48,7 @@ describe "CApiFixnumSpecs" do end it "converts a Fixnum" do + @s.rb_fix2uint(0).should == 0 @s.rb_fix2uint(1).should == 1 end @@ -25,6 +60,12 @@ describe "CApiFixnumSpecs" do @s.rb_fix2uint(25.4567).should == 25 end + it "raises a RangeError if the value does not fit a native uint" do + # Interestingly, on MRI rb_fix2uint(-1) is allowed + lambda { @s.rb_fix2uint(0xffff_ffff+1) }.should raise_error(RangeError) + lambda { @s.rb_fix2uint(-(1 << 31) - 1) }.should raise_error(RangeError) + end + it "raises a RangeError if the value is more than 32bits" do lambda { @s.rb_fix2uint(0xffff_ffff+1) }.should raise_error(RangeError) end @@ -44,7 +85,11 @@ describe "CApiFixnumSpecs" do @s.rb_fix2int(1).should == 1 end - it "converts the maximum uint value" do + it "converts the minimum int value" do + @s.rb_fix2int(-(1 << 31)).should == -(1 << 31) + end + + it "converts the maximum int value" do @s.rb_fix2int(0x7fff_ffff).should == 0x7fff_ffff end @@ -56,6 +101,11 @@ describe "CApiFixnumSpecs" do @s.rb_fix2int(-2147442171).should == -2147442171 end + it "raises a RangeError if the value does not fit a native int" do + lambda { @s.rb_fix2int(0x7fff_ffff+1) }.should raise_error(RangeError) + lambda { @s.rb_fix2int(-(1 << 31) - 1) }.should raise_error(RangeError) + end + it "raises a RangeError if the value is more than 32bits" do lambda { @s.rb_fix2int(0xffff_ffff+1) }.should raise_error(RangeError) end diff --git a/spec/rubyspec/optional/capi/gc_spec.rb b/spec/rubyspec/optional/capi/gc_spec.rb index 71efef3fad..ee9e11d11c 100644 --- a/spec/rubyspec/optional/capi/gc_spec.rb +++ b/spec/rubyspec/optional/capi/gc_spec.rb @@ -41,4 +41,14 @@ describe "CApiGCSpecs" do end end + describe "rb_gc" do + + it "increases gc count" do + gc_count = GC.count + @f.rb_gc + GC.count.should > gc_count + end + + end + end diff --git a/spec/rubyspec/optional/capi/hash_spec.rb b/spec/rubyspec/optional/capi/hash_spec.rb index 15284566f1..1c406f0394 100644 --- a/spec/rubyspec/optional/capi/hash_spec.rb +++ b/spec/rubyspec/optional/capi/hash_spec.rb @@ -119,6 +119,25 @@ describe "C-API Hash function" do end end + describe "rb_hash_fetch" do + before :each do + @hsh = {:a => 1, :b => 2} + end + + it "returns the value associated with the key" do + @s.rb_hash_fetch(@hsh, :b).should == 2 + end + + it "raises a KeyError if the key is not found and default is set" do + @hsh.default = :d + lambda { @s.rb_hash_fetch(@hsh, :c) }.should raise_error(KeyError) + end + + it "raises a KeyError if the key is not found and no default is set" do + lambda { @s.rb_hash_fetch(@hsh, :c) }.should raise_error(KeyError) + end + end + describe "rb_hash_foreach" do it "iterates over the hash" do hsh = {name: "Evan", sign: :libra} diff --git a/spec/rubyspec/optional/capi/proc_spec.rb b/spec/rubyspec/optional/capi/proc_spec.rb index c325e0fdfc..1cd8de9a86 100644 --- a/spec/rubyspec/optional/capi/proc_spec.rb +++ b/spec/rubyspec/optional/capi/proc_spec.rb @@ -40,6 +40,20 @@ describe "C-API Proc function" do @prc.source_location.should == nil end end + + describe "rb_proc_arity" do + it "returns the correct arity" do + prc = Proc.new {|a,b,c|} + @p.rb_proc_arity(prc).should == 3 + end + end + + describe "rb_proc_call" do + it "calls the Proc" do + prc = Proc.new {|a,b| a * b } + @p.rb_proc_call(prc, [6, 7]).should == 42 + end + end end describe "C-API when calling Proc.new from a C function" do diff --git a/spec/rubyspec/optional/capi/range_spec.rb b/spec/rubyspec/optional/capi/range_spec.rb index b145079f39..aa16f9773e 100644 --- a/spec/rubyspec/optional/capi/range_spec.rb +++ b/spec/rubyspec/optional/capi/range_spec.rb @@ -65,4 +65,31 @@ describe "C-API Range function" do excl.should be_false end end + + describe "rb_range_beg_len" do + it "returns correct begin, length and result" do + r = 2..5 + begp, lenp, result = @s.rb_range_beg_len(r, 0, 0, 10, 0) + result.should be_true + begp.should == 2 + lenp.should == 4 + end + + it "returns nil when not in range" do + r = 2..5 + begp, lenp, result = @s.rb_range_beg_len(r, 0, 0, 1, 0) + result.should be_nil + end + + it "raises a RangeError when not in range and err is 1" do + r = -5..-1 + lambda { @s.rb_range_beg_len(r, 0, 0, 1, 1) }.should raise_error(RangeError) + end + + it "returns nil when not in range and err is 0" do + r = -5..-1 + begp, lenp, result = @s.rb_range_beg_len(r, 0, 0, 1, 0) + result.should be_nil + end + end end diff --git a/spec/rubyspec/optional/capi/st_spec.rb b/spec/rubyspec/optional/capi/st_spec.rb new file mode 100644 index 0000000000..7f2bc08c62 --- /dev/null +++ b/spec/rubyspec/optional/capi/st_spec.rb @@ -0,0 +1,41 @@ +# encoding: utf-8 +require File.expand_path('../spec_helper', __FILE__) + +load_extension('st') + +describe "st hash table function" do + before :each do + @s = CApiStSpecs.new + end + + describe "st_init_numtable" do + it "initializes without error" do + @s.st_init_numtable.should == 0 + end + end + + describe "st_init_numtable_with_size" do + it "initializes without error" do + @s.st_init_numtable_with_size.should == 0 + end + end + + describe "st_insert" do + it "returns size 1 after insert" do + @s.st_insert.should == 1 + end + end + + describe "st_foreach" do + it "iterates over each pair of key and value" do + @s.st_foreach.should == 7 + end + end + + describe "st_lookup" do + it "returns the expected value" do + @s.st_lookup.should == 42 + end + end + +end diff --git a/spec/rubyspec/optional/capi/string_spec.rb b/spec/rubyspec/optional/capi/string_spec.rb index 7528a71682..25ef10b6f6 100644 --- a/spec/rubyspec/optional/capi/string_spec.rb +++ b/spec/rubyspec/optional/capi/string_spec.rb @@ -228,6 +228,22 @@ describe "C-API String function" do end end + describe "rb_tainted_str_new" do + it "creates a new tainted String" do + newstring = @s.rb_tainted_str_new("test", 4) + newstring.should == "test" + newstring.tainted?.should be_true + end + end + + describe "rb_tainted_str_new2" do + it "creates a new tainted String" do + newstring = @s.rb_tainted_str_new2("test") + newstring.should == "test" + newstring.tainted?.should be_true + end + end + describe "rb_str_append" do it "appends a string to another string" do @s.rb_str_append("Hello", " Goodbye").should == "Hello Goodbye" |