File: testVariableAndMethod.rb

package info (click to toggle)
jruby 1.5.6-9
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 45,088 kB
  • ctags: 77,093
  • sloc: ruby: 398,491; java: 170,202; yacc: 3,782; xml: 2,529; sh: 299; tcl: 40; makefile: 35; ansic: 23
file content (31 lines) | stat: -rw-r--r-- 563 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'test/minirunit'
test_check "Test Variables and method:"
a = String.new("Hello World")
b = a.reverse
c = " "
d = "Hello".reverse
e = a[6, 5].reverse

f = 100 + 35
g =  2 * 10
h = 13 % 5
test_ok("Hello World" ==  a)
test_ok("dlroW olleH" == b)
test_ok("Hello" == d.reverse)
test_ok("World" == e.reverse)
test_ok(135 == f)
test_ok(20 == g)
test_ok(3 == h)
$a = a
$b = b
$c = c
$d = d
$e = e
$f = f
$g = g
$h = h
NIL_CONSTANT=nil
test_ok(NIL_CONSTANT == nil)
test_exception(NameError) { NO_SUCH_CONSTANT }

x, (y, z) = 1, 2, 3; test_ok([1,2,nil] == [x,y,z])