rsruby 0.4.0 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/test/tc_robj.rb CHANGED
@@ -1,20 +1,17 @@
1
1
  require 'test/unit'
2
2
  require 'rsruby'
3
3
 
4
- unless $r
5
- $r = RSRuby.instance
6
- end
7
-
8
4
  class TestRObj < Test::Unit::TestCase
9
5
 
10
6
  def setup
7
+ @r = RSRuby.instance
11
8
  RSRuby.set_default_mode(RSRuby::NO_DEFAULT)
12
- $r.class_table.clear
13
- $r.proc_table.clear
9
+ @r.class_table.clear
10
+ @r.proc_table.clear
14
11
  end
15
12
 
16
13
  def test_type
17
- assert_equal($r.array.class, RObj)
14
+ assert_equal(@r.array.class, RObj)
18
15
  end
19
16
 
20
17
  def test_call
@@ -25,8 +22,8 @@ class TestRObj < Test::Unit::TestCase
25
22
  #TODO - In RPy keyword parameters are converted like the method calls
26
23
  #In ruby this isn't such a problem because you can use quoted strings
27
24
  #but we will implement it anyway.
28
- $r.list.autoconvert(RSRuby::BASIC_CONVERSION)
29
- d = $r.list(:foo => 'foo', :bar_foo => 'bar.foo', :print_ => 'print', :as_data_frame => 'as.data.frame')
25
+ @r.list.autoconvert(RSRuby::BASIC_CONVERSION)
26
+ d = @r.list(:foo => 'foo', :bar_foo => 'bar.foo', :print_ => 'print', :as_data_frame => 'as.data.frame')
30
27
  d.each do |k,v|
31
28
  assert_equal(k, d[k])
32
29
  end
@@ -34,54 +31,54 @@ class TestRObj < Test::Unit::TestCase
34
31
 
35
32
  def test_bad_keyword_parameters
36
33
  #TODO?
37
- #assert_raises(ArgumentError){$r.list(:none => 1)}
34
+ #assert_raises(ArgumentError){@r.list(:none => 1)}
38
35
  end
39
36
 
40
37
  def test_name_conversions
41
- assert_equal($r.array, $r['array'])
42
- assert_equal($r.print_,$r['print'])
43
- assert_equal($r.as_data_frame, $r['as.data.frame'])
44
- assert_equal($r.attr__, $r['attr<-'])
38
+ assert_equal(@r.array, @r['array'])
39
+ assert_equal(@r.print_,@r['print'])
40
+ assert_equal(@r.as_data_frame, @r['as.data.frame'])
41
+ assert_equal(@r.attr__, @r['attr<-'])
45
42
  end
46
43
 
47
44
  def test_not_found
48
- assert_raises(RException){$r.foo}
45
+ assert_raises(RException){@r.foo}
49
46
  end
50
47
 
51
48
  def test_name_length_one
52
- assert_nothing_raised{$r.T}
49
+ assert_nothing_raised{@r.T}
53
50
  end
54
51
 
55
52
  def test_autoconvert
56
- $r.seq.autoconvert(RSRuby::BASIC_CONVERSION)
57
- assert_equal($r.seq(10), (1..10).to_a)
58
- $r.seq.autoconvert(RSRuby::NO_CONVERSION)
59
- assert_equal($r.seq(10).class, RObj)
53
+ @r.seq.autoconvert(RSRuby::BASIC_CONVERSION)
54
+ assert_equal(@r.seq(10), (1..10).to_a)
55
+ @r.seq.autoconvert(RSRuby::NO_CONVERSION)
56
+ assert_equal(@r.seq(10).class, RObj)
60
57
  end
61
58
 
62
59
  def test_bad_autoconvert
63
- assert_raises(ArgumentError){$r.seq.autoconvert(RSRuby::TOP_CONVERSION+1)}
60
+ assert_raises(ArgumentError){@r.seq.autoconvert(RSRuby::TOP_CONVERSION+1)}
64
61
  end
65
62
 
66
63
  def test_get_autoconvert
67
- $r.seq.autoconvert(RSRuby::BASIC_CONVERSION)
68
- mode = $r.seq.autoconvert
64
+ @r.seq.autoconvert(RSRuby::BASIC_CONVERSION)
65
+ mode = @r.seq.autoconvert
69
66
  assert_equal(mode, RSRuby::BASIC_CONVERSION)
70
67
  end
71
68
 
72
69
  def test_r_gc
73
70
  #TODO - How can this work?
74
- $r.seq.autoconvert(RSRuby::NO_CONVERSION)
75
- arr = $r.seq(100000)
76
- $r.gc
77
- assert($r['['].call(arr,10))
71
+ @r.seq.autoconvert(RSRuby::NO_CONVERSION)
72
+ arr = @r.seq(100000)
73
+ @r.gc
74
+ assert(@r['['].call(arr,10))
78
75
  end
79
76
 
80
77
  def test_lcall
81
78
  RSRuby.set_default_mode(RSRuby::NO_CONVERSION)
82
- arr = $r.c.lcall([['',0],['a',1],['b',2],['c',3]])
79
+ arr = @r.c.lcall([['',0],['a',1],['b',2],['c',3]])
83
80
  RSRuby.set_default_mode(RSRuby::BASIC_CONVERSION)
84
- assert_equal($r.names(arr), ['','a','b','c'])
81
+ assert_equal(@r.names(arr), ['','a','b','c'])
85
82
  end
86
83
 
87
84
  end
data/test/tc_sigint.rb CHANGED
@@ -4,7 +4,7 @@ require 'rsruby'
4
4
  class TestSigint < Test::Unit::TestCase
5
5
 
6
6
  def test_sigint
7
- assert_raises(SystemExit){Process.kill('SIGINT',0)}
7
+ assert_raises(KeyboardInterrupt){Process.kill('SIGINT',0)}
8
8
  end
9
9
 
10
10
  end
data/test/tc_to_r.rb CHANGED
@@ -1,10 +1,6 @@
1
1
  require 'test/unit'
2
2
  require 'rsruby'
3
3
 
4
- unless $r
5
- $r = RSRuby.instance
6
- end
7
-
8
4
  class Foo
9
5
  end
10
6
 
@@ -20,114 +16,115 @@ end
20
16
  class TestToR < Test::Unit::TestCase
21
17
 
22
18
  def setup
19
+ @r = RSRuby.instance
23
20
  RSRuby.set_default_mode(RSRuby::NO_DEFAULT)
24
21
  end
25
22
 
26
23
  def test_robj_to_r
27
24
 
28
- $r.c.autoconvert(RSRuby::NO_CONVERSION)
25
+ @r.c.autoconvert(RSRuby::NO_CONVERSION)
29
26
 
30
- r1 = $r.c(4)
31
- r2 = $r.c('foo')
32
- r3 = $r.c(['a','b'])
27
+ r1 = @r.c(4)
28
+ r2 = @r.c('foo')
29
+ r3 = @r.c(['a','b'])
33
30
 
34
- assert($r['=='].call(r1,4))
35
- assert($r['=='].call(r2,'foo'))
36
- assert($r['=='].call(r3,['a','b']))
31
+ assert(@r['=='].call(r1,4))
32
+ assert(@r['=='].call(r2,'foo'))
33
+ assert(@r['=='].call(r3,['a','b']))
37
34
 
38
- assert_equal($r.typeof($r.eval),'closure')
39
- assert_equal($r.typeof($r.eval($r.eval)), 'closure')
40
- assert_equal($r.typeof($r.eval([$r.eval,$r.eval])), 'list')
35
+ assert_equal(@r.typeof(@r.eval),'closure')
36
+ assert_equal(@r.typeof(@r.eval(@r.eval)), 'closure')
37
+ assert_equal(@r.typeof(@r.eval([@r.eval,@r.eval])), 'list')
41
38
 
42
39
  #Same tests as above in basic mode - should be identical
43
- $r.c.autoconvert(RSRuby::BASIC_CONVERSION)
40
+ @r.c.autoconvert(RSRuby::BASIC_CONVERSION)
44
41
 
45
- r1 = $r.c(4)
46
- r2 = $r.c('foo')
47
- r3 = $r.c(['a','b'])
42
+ r1 = @r.c(4)
43
+ r2 = @r.c('foo')
44
+ r3 = @r.c(['a','b'])
48
45
 
49
- assert($r['=='].call(r1,4))
50
- assert($r['=='].call(r2,'foo'))
51
- assert($r['=='].call(r3,['a','b']))
46
+ assert(@r['=='].call(r1,4))
47
+ assert(@r['=='].call(r2,'foo'))
48
+ assert(@r['=='].call(r3,['a','b']))
52
49
 
53
- assert_equal($r.typeof($r.eval),'closure')
54
- assert_equal($r.typeof($r.eval($r.eval)), 'closure')
55
- assert_equal($r.typeof($r.eval([$r.eval,$r.eval])), 'list')
50
+ assert_equal(@r.typeof(@r.eval),'closure')
51
+ assert_equal(@r.typeof(@r.eval(@r.eval)), 'closure')
52
+ assert_equal(@r.typeof(@r.eval([@r.eval,@r.eval])), 'list')
56
53
 
57
54
  end
58
55
 
59
56
  def test_empty_array_to_null
60
- assert($r.is_null([]))
57
+ assert(@r.is_null([]))
61
58
  end
62
59
 
63
60
  def test_boolean_to_logical
64
- assert_equal($r.c(true),true)
65
- assert_equal($r.c(true).class,true.class)
66
- assert_equal($r.c(false),false)
67
- assert_equal($r.c(false).class,false.class)
61
+ assert_equal(@r.c(true),true)
62
+ assert_equal(@r.c(true).class,true.class)
63
+ assert_equal(@r.c(false),false)
64
+ assert_equal(@r.c(false).class,false.class)
68
65
  end
69
66
 
70
67
  def test_int_to_int
71
- $r.c.autoconvert(RSRuby::NO_CONVERSION)
72
- assert_equal($r.typeof($r.c(4)), 'integer')
73
- $r.c.autoconvert(RSRuby::BASIC_CONVERSION)
74
- assert_equal($r.typeof($r.c(4)), 'integer')
68
+ @r.c.autoconvert(RSRuby::NO_CONVERSION)
69
+ assert_equal(@r.typeof(@r.c(4)), 'integer')
70
+ @r.c.autoconvert(RSRuby::BASIC_CONVERSION)
71
+ assert_equal(@r.typeof(@r.c(4)), 'integer')
75
72
  end
76
73
 
77
74
  def test_float_to_float
78
- $r.c.autoconvert(RSRuby::NO_CONVERSION)
79
- assert_equal($r.typeof($r.c(4.5)), 'double')
80
- $r.c.autoconvert(RSRuby::BASIC_CONVERSION)
81
- assert_equal($r.typeof($r.c(4.5)), 'double')
75
+ @r.c.autoconvert(RSRuby::NO_CONVERSION)
76
+ assert_equal(@r.typeof(@r.c(4.5)), 'double')
77
+ @r.c.autoconvert(RSRuby::BASIC_CONVERSION)
78
+ assert_equal(@r.typeof(@r.c(4.5)), 'double')
82
79
  end
83
80
 
84
81
  def test_char_to_char
85
- $r.c.autoconvert(RSRuby::NO_CONVERSION)
86
- assert_equal($r.typeof($r.c('foo')), 'character')
87
- $r.c.autoconvert(RSRuby::BASIC_CONVERSION)
88
- assert_equal($r.typeof($r.c('foo')), 'character')
82
+ @r.c.autoconvert(RSRuby::NO_CONVERSION)
83
+ assert_equal(@r.typeof(@r.c('foo')), 'character')
84
+ @r.c.autoconvert(RSRuby::BASIC_CONVERSION)
85
+ assert_equal(@r.typeof(@r.c('foo')), 'character')
89
86
  end
90
87
 
91
88
  def test_hash_to_named_vector
92
- $r.c.autoconvert(RSRuby::NO_CONVERSION)
93
- assert_equal($r.typeof($r.c(:foo => 5, :bar => 7)),'integer')
94
- assert($r.attributes($r.c(:foo => 5, :bar => 7))['names'].include?('foo'))
95
- assert($r.attributes($r.c(:foo => 5, :bar => 7))['names'].include?('bar'))
89
+ @r.c.autoconvert(RSRuby::NO_CONVERSION)
90
+ assert_equal(@r.typeof(@r.c(:foo => 5, :bar => 7)),'integer')
91
+ assert(@r.attributes(@r.c(:foo => 5, :bar => 7))['names'].include?('foo'))
92
+ assert(@r.attributes(@r.c(:foo => 5, :bar => 7))['names'].include?('bar'))
96
93
  #TODO - these fail because of the different calling semantics in
97
94
  #RSRuby
98
- #$r.c.autoconvert(RSRuby::BASIC_CONVERSION)
99
- #assert_equal($r.typeof($r.c(:foo => 5, :bar => 7)),'integer')
100
- #assert($r.attributes($r.c(:foo => 5, :bar => 7))['names'].include?('foo'))
101
- #assert($r.attributes($r.c(:foo => 5, :bar => 7))['names'].include?('bar'))
95
+ #@r.c.autoconvert(RSRuby::BASIC_CONVERSION)
96
+ #assert_equal(@r.typeof(@r.c(:foo => 5, :bar => 7)),'integer')
97
+ #assert(@r.attributes(@r.c(:foo => 5, :bar => 7))['names'].include?('foo'))
98
+ #assert(@r.attributes(@r.c(:foo => 5, :bar => 7))['names'].include?('bar'))
102
99
  end
103
100
 
104
101
  def test_array_to_vector
105
- $r.c.autoconvert(RSRuby::NO_CONVERSION)
106
- assert_equal($r.length($r.c(1,2,3,4)),4)
107
- $r.c.autoconvert(RSRuby::BASIC_CONVERSION)
108
- assert_equal($r.length($r.c(1,2,3,4)),4)
102
+ @r.c.autoconvert(RSRuby::NO_CONVERSION)
103
+ assert_equal(@r.length(@r.c(1,2,3,4)),4)
104
+ @r.c.autoconvert(RSRuby::BASIC_CONVERSION)
105
+ assert_equal(@r.length(@r.c(1,2,3,4)),4)
109
106
  end
110
107
 
111
108
  def test_not_convertible
112
109
  #TODO - range?
113
- assert_raises(ArgumentError){$r.c(1..10)}
110
+ assert_raises(ArgumentError){@r.c(1..10)}
114
111
  end
115
112
 
116
113
  def test_instances_not_convertible
117
114
  foo = Foo.new
118
- assert_raises(ArgumentError){$r.c(foo)}
115
+ assert_raises(ArgumentError){@r.c(foo)}
119
116
  end
120
117
 
121
118
  def test_as_r_method
122
- $r.c.autoconvert(RSRuby::BASIC_CONVERSION)
119
+ @r.c.autoconvert(RSRuby::BASIC_CONVERSION)
123
120
 
124
121
  a = Bar.new(3)
125
122
  b = Bar.new('foo')
126
- d = Bar.new($r.seq)
123
+ d = Bar.new(@r.seq)
127
124
 
128
- assert_equal($r.c(a),3)
129
- assert_equal($r.c(b),'foo')
130
- assert_equal($r.c(d).call(1,3),[1,2,3])
125
+ assert_equal(@r.c(a),3)
126
+ assert_equal(@r.c(b),'foo')
127
+ assert_equal(@r.c(d).call(1,3),[1,2,3])
131
128
 
132
129
  end
133
130
 
data/test/tc_to_ruby.rb CHANGED
@@ -1,51 +1,48 @@
1
1
  require 'test/unit'
2
2
  require 'rsruby'
3
3
 
4
- unless $r
5
- $r = RSRuby.instance
6
- end
7
-
8
4
  class TestToRuby < Test::Unit::TestCase
9
5
 
10
6
  def setup
7
+ @r = RSRuby.instance
11
8
  RSRuby.set_default_mode(RSRuby::NO_DEFAULT)
12
- $r.seq.autoconvert(RSRuby::BASIC_CONVERSION)
13
- $r.c.autoconvert(RSRuby::BASIC_CONVERSION)
9
+ @r.seq.autoconvert(RSRuby::BASIC_CONVERSION)
10
+ @r.c.autoconvert(RSRuby::BASIC_CONVERSION)
14
11
  end
15
12
 
16
13
  def test_null_to_nil
17
- assert($r.attributes($r.seq).nil?)
14
+ assert(@r.attributes(@r.seq).nil?)
18
15
  end
19
16
 
20
17
  def test_factor_to_list
21
- assert_equal($r.factor([1,2,3,4]), ['1','2','3','4'])
22
- assert_equal($r.factor([1,1,1,2]), ['1','1','1','2'])
23
- assert_equal($r.factor(['a','b','c']), ['a','b','c'])
18
+ assert_equal(@r.factor([1,2,3,4]), ['1','2','3','4'])
19
+ assert_equal(@r.factor([1,1,1,2]), ['1','1','1','2'])
20
+ assert_equal(@r.factor(['a','b','c']), ['a','b','c'])
24
21
  end
25
22
 
26
23
  def test_NA_int
27
24
  #The formula on right should equal smallest Fixnum
28
25
  #in current Ruby build (can vary)
29
- assert_equal($r.NA, (-1)*(2**((1.size*8)-1)))
30
- assert($r.is_na($r.NA))
26
+ assert_equal(@r.NA, (-1)*(2**((1.size*8)-1)))
27
+ assert(@r.is_na(@r.NA))
31
28
  end
32
29
 
33
30
  def test_NA_string
34
- assert_equal($r.eval_R('as.character(NA)'), 'NA')
35
- assert_equal($r.as_character($r.NA), 'NA')
36
- assert_equal($r.as_character($r.NaN), 'NaN')
31
+ assert_equal(@r.eval_R('as.character(NA)'), 'NA')
32
+ assert_equal(@r.as_character(@r.NA), 'NA')
33
+ assert_equal(@r.as_character(@r.NaN), 'NaN')
37
34
  end
38
35
 
39
36
  def test_factor_NA
40
- assert_equal($r.factor($r.NA) , 'NA')
41
- assert_equal($r.factor($r.NaN), 'NaN')
42
- assert_equal($r.factor($r.as_character('NA')), 'NA')
37
+ assert_equal(@r.factor(@r.NA) , 'NA')
38
+ assert_equal(@r.factor(@r.NaN), 'NaN')
39
+ assert_equal(@r.factor(@r.as_character('NA')), 'NA')
43
40
 
44
- xi = [1,2,$r.NA,$r.NaN,4]
45
- assert_equal($r.factor(xi), ['1','2','NA','NaN','4'])
41
+ xi = [1,2,@r.NA,@r.NaN,4]
42
+ assert_equal(@r.factor(xi), ['1','2','NA','NaN','4'])
46
43
 
47
- xd = [1.01,2.02,$r.NA,$r.NaN,4.04]
48
- assert_equal($r.factor(xd), ['1.01','2.02','NA','NaN','4.04'])
44
+ xd = [1.01,2.02,@r.NA,@r.NaN,4.04]
45
+ assert_equal(@r.factor(xd), ['1.01','2.02','NA','NaN','4.04'])
49
46
 
50
47
  end
51
48
 
@@ -55,25 +52,25 @@ class TestToRuby < Test::Unit::TestCase
55
52
  #The conversion between NA/NaN and Ruby seems a little confused
56
53
  #at the moment
57
54
 
58
- xi = [1,2,$r.NA,$r.NaN,4]
59
- assert_equal($r.as_character(xi), ['1','2','NA','NaN','4'])
60
- #assert_equal($r.as_numeric(xi) , [1.0,2.0,$r.NA,$r.NaN,4.0])
61
- #assert_equal($r.as_integer(xi) , [1,2,$r.NA,$r.NaN,4])
62
- assert_equal($r.factor(xi) , ['1','2','NA','NaN','4'])
63
- assert_equal($r.is_na(xi) , [false, false, true, true, false])
55
+ xi = [1,2,@r.NA,@r.NaN,4]
56
+ assert_equal(@r.as_character(xi), ['1','2','NA','NaN','4'])
57
+ #assert_equal(@r.as_numeric(xi) , [1.0,2.0,@r.NA,@r.NaN,4.0])
58
+ #assert_equal(@r.as_integer(xi) , [1,2,@r.NA,@r.NaN,4])
59
+ assert_equal(@r.factor(xi) , ['1','2','NA','NaN','4'])
60
+ assert_equal(@r.is_na(xi) , [false, false, true, true, false])
64
61
 
65
- xd = [1.01,2.02,$r.NA,$r.NaN,4.04]
66
- assert_equal($r.as_character(xd), ['1.01','2.02','NA','NaN','4.04'])
67
- #assert_equal($r.as_numeric(xi) , [1.01,2.01,$r.NA,$r.NaN,4.01])
68
- assert_equal($r.as_integer(xd) , [1,2,$r.NA,$r.NA,4])
69
- assert_equal($r.factor(xd) , ['1.01','2.02','NA','NaN','4.04'])
70
- assert_equal($r.is_na(xd) , [false, false, true, true, false])
62
+ xd = [1.01,2.02,@r.NA,@r.NaN,4.04]
63
+ assert_equal(@r.as_character(xd), ['1.01','2.02','NA','NaN','4.04'])
64
+ #assert_equal(@r.as_numeric(xi) , [1.01,2.01,@r.NA,@r.NaN,4.01])
65
+ assert_equal(@r.as_integer(xd) , [1,2,@r.NA,@r.NA,4])
66
+ assert_equal(@r.factor(xd) , ['1.01','2.02','NA','NaN','4.04'])
67
+ assert_equal(@r.is_na(xd) , [false, false, true, true, false])
71
68
  end
72
69
 
73
70
  #TODO - table.txt?????????
74
71
  def test_dataframe_to_list
75
- $r.read_table.autoconvert(RSRuby::BASIC_CONVERSION)
76
- assert_equal($r.read_table('test/table.txt', {:header => 1}),
72
+ @r.read_table.autoconvert(RSRuby::BASIC_CONVERSION)
73
+ assert_equal(@r.read_table("test/table.txt", {:header => 1}),
77
74
  {
78
75
  'A' => ['X1','X2','X3'],
79
76
  'C' => [5,8,2],
@@ -83,73 +80,73 @@ class TestToRuby < Test::Unit::TestCase
83
80
  end
84
81
 
85
82
  def test_logical_to_boolean
86
- assert_equal($r.TRUE, true)
87
- assert_equal($r.T, true)
88
- assert_equal($r.FALSE, false)
89
- assert_equal($r.F, false)
83
+ assert_equal(@r.TRUE, true)
84
+ assert_equal(@r.T, true)
85
+ assert_equal(@r.FALSE, false)
86
+ assert_equal(@r.F, false)
90
87
  end
91
88
 
92
89
  def test_int_to_int
93
- assert_equal($r.as_integer(5),5)
94
- assert_equal($r.as_integer(-3),-3)
90
+ assert_equal(@r.as_integer(5),5)
91
+ assert_equal(@r.as_integer(-3),-3)
95
92
  end
96
93
 
97
94
  def test_float_to_float
98
- assert_equal($r.as_real(5),5.0)
99
- assert_equal($r.as_real(3.1),3.1)
100
- assert_equal($r.as_real(-3.1), -3.1)
95
+ assert_equal(@r.as_real(5),5.0)
96
+ assert_equal(@r.as_real(3.1),3.1)
97
+ assert_equal(@r.as_real(-3.1), -3.1)
101
98
  end
102
99
 
103
100
  def test_complex_to_complex
104
101
  #TODO - Think about Complex support
105
- assert_equal($r.as_complex(Complex(1,2)), Complex(1,2))
106
- assert_equal($r.as_complex(Complex(1.5,-3.4)), Complex(1.5,-3.4))
102
+ assert_equal(@r.as_complex(Complex(1,2)), Complex(1,2))
103
+ assert_equal(@r.as_complex(Complex(1.5,-3.4)), Complex(1.5,-3.4))
107
104
  end
108
105
 
109
106
  def test_str_to_str
110
- $r.as_data_frame.autoconvert(RSRuby::NO_CONVERSION)
111
- assert_equal($r.class_($r.as_data_frame([1,2,3])), 'data.frame')
107
+ @r.as_data_frame.autoconvert(RSRuby::NO_CONVERSION)
108
+ assert_equal(@r.class_(@r.as_data_frame([1,2,3])), 'data.frame')
112
109
  end
113
110
 
114
111
  def test_vector_length_one
115
- assert_equal($r.c(1),1)
116
- assert_equal($r.c('foo'),'foo')
112
+ assert_equal(@r.c(1),1)
113
+ assert_equal(@r.c('foo'),'foo')
117
114
  end
118
115
 
119
116
  def test_int_vector_to_array
120
- assert_equal($r.seq(10),[1,2,3,4,5,6,7,8,9,10])
117
+ assert_equal(@r.seq(10),[1,2,3,4,5,6,7,8,9,10])
121
118
  end
122
119
 
123
120
  def test_float_vector_to_array
124
- assert_equal($r.seq(1,2,{:by => 0.5}), [1.0,1.5,2.0])
121
+ assert_equal(@r.seq(1,2,{:by => 0.5}), [1.0,1.5,2.0])
125
122
  end
126
123
 
127
124
  def test_complex_vector_to_array
128
- assert_equal($r.c(Complex(1,2),Complex(2,-3)),[Complex(1,2),Complex(2,-3)])
125
+ assert_equal(@r.c(Complex(1,2),Complex(2,-3)),[Complex(1,2),Complex(2,-3)])
129
126
  end
130
127
 
131
128
  def test_str_vector_to_array
132
- assert_equal($r.c('Foo','Bar'),['Foo','Bar'])
129
+ assert_equal(@r.c('Foo','Bar'),['Foo','Bar'])
133
130
  end
134
131
 
135
132
  def test_list_to_array
136
- $r.list.autoconvert(RSRuby::BASIC_CONVERSION)
137
- assert_equal($r.list(1,2.0,'foo'),[1,2.0,'foo'])
133
+ @r.list.autoconvert(RSRuby::BASIC_CONVERSION)
134
+ assert_equal(@r.list(1,2.0,'foo'),[1,2.0,'foo'])
138
135
  end
139
136
 
140
137
  def test_named_vector_to_hash
141
- $r.c.autoconvert(RSRuby::NO_CONVERSION)
142
- a = $r.attr__($r.c(1,2,3), 'names', ['foo','bar','baz'])
138
+ @r.c.autoconvert(RSRuby::NO_CONVERSION)
139
+ a = @r.attr__(@r.c(1,2,3), 'names', ['foo','bar','baz'])
143
140
  assert_equal(a,{'foo'=>1,'bar'=>2,'baz'=>3})
144
- assert_equal($r.list(:foo => 1, :bar => 2, :baz => 3),{'foo'=>1,'bar'=>2,'baz'=>3})
141
+ assert_equal(@r.list(:foo => 1, :bar => 2, :baz => 3),{'foo'=>1,'bar'=>2,'baz'=>3})
145
142
  end
146
143
 
147
144
  def test_vector_coercion
148
- $r.c.autoconvert(RSRuby::NO_CONVERSION)
149
- assert_equal($r.typeof($r.c(1,2,3)), 'integer')
150
- assert_equal($r.typeof($r.c(1,2.0,3)), 'double')
151
- assert_equal($r.typeof($r.c(1,Complex(2,3),3)), 'complex')
152
- assert_equal($r.typeof($r.c(1,'foo',3)), 'character')
145
+ @r.c.autoconvert(RSRuby::NO_CONVERSION)
146
+ assert_equal(@r.typeof(@r.c(1,2,3)), 'integer')
147
+ assert_equal(@r.typeof(@r.c(1,2.0,3)), 'double')
148
+ assert_equal(@r.typeof(@r.c(1,Complex(2,3),3)), 'complex')
149
+ assert_equal(@r.typeof(@r.c(1,'foo',3)), 'character')
153
150
  end
154
151
 
155
152
  end