1 require File.dirname(__FILE__) + '/../spec_helper'
2 require File.dirname(__FILE__) + '/subtend_helper'
4 compile_extension('subtend_global')
5 require File.dirname(__FILE__) + '/ext/subtend_global'
7 describe "SubtendGlobal" do
12 it "correctly gets global values" do
13 @f.sb_gv_get("$BLAH").should == nil
14 @f.sb_gv_get("$SAFE").should == 0
15 @f.sb_gv_get("SAFE").should == 0 # rb_gv_get should change SAFE to $SAFE
18 it "correctly sets global values" do
19 @f.sb_gv_get("$BLAH").should == nil
20 @f.sb_gv_set("$BLAH", 10)
21 @f.sb_gv_get("$BLAH").should == 10
24 it "rb_define_variable should define a new global variable" do
25 @f.rb_define_variable("my_gvar", "ABC")
26 $my_gvar.should == "ABC"
28 @f.sb_get_global_value.should == "XYZ"
31 it "rb_define_readonly_variable should define a new readonly global variable" do
32 @f.rb_define_readonly_variable("ro_gvar", 15)
34 lambda { $ro_gvar = 10 }.should raise_error(NameError)
37 it "rb_define_hooked_variable should define a C hooked global variable" do
38 @f.rb_define_hooked_variable_2x("$hooked_gvar")
40 $hooked_gvar.should == 4