Skip to content
This repository has been archived by the owner on Jun 9, 2018. It is now read-only.

Commit

Permalink
refactor tests with isa_ok
Browse files Browse the repository at this point in the history
  • Loading branch information
fperrad committed Sep 7, 2009
1 parent 2510c17 commit 097b717
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 100 deletions.
12 changes: 4 additions & 8 deletions t/pmc/boolean_hll.t
Expand Up @@ -34,16 +34,14 @@ Tests C<LuaBoolean> PMC
set $P0, 1
$S0 = $P0
is($S0, 'true', "check HLL")
$I0 = isa $P0, 'LuaBoolean'
ok($I0)
isa_ok($P0, 'LuaBoolean')
.end

.sub 'check_HLL_const'
.const 'LuaBoolean' K = '1'
$S0 = K
is($S0, 'true', "check HLL & .const")
$I0 = isa K, 'LuaBoolean'
ok($I0)
isa_ok(K, 'LuaBoolean')
.end

.sub 'check_tostring'
Expand All @@ -52,8 +50,7 @@ Tests C<LuaBoolean> PMC
$S0 = $P0
is($S0, 'true', "check tostring")
$P1 = $P0.'tostring'()
$I0 = isa $P1, 'LuaString'
ok($I0)
isa_ok($P1, 'LuaString')
$S0 = $P1
is($S0, 'true')
.end
Expand All @@ -64,8 +61,7 @@ Tests C<LuaBoolean> PMC
$S0 = $P0
is($S0, 'true', "check tonumber")
$P1 = $P0.'tonumber'()
$I0 = isa $P1, 'LuaNil'
ok($I0)
isa_ok($P1, 'LuaNil')
.end

# Local Variables:
Expand Down
3 changes: 1 addition & 2 deletions t/pmc/function.t
Expand Up @@ -83,8 +83,7 @@ Tests C<LuaFunction> PMC
.sub 'check_logical_not'
$P0 = new 'LuaFunction'
$P1 = not $P0
$I0 = isa $P1, 'LuaBoolean'
ok($I0, "check logical_not")
isa_ok($P1, 'LuaBoolean', "check logical_not")
$S0 = $P1
is($S0, 'false')
.end
Expand Down
27 changes: 9 additions & 18 deletions t/pmc/function_hll.t
Expand Up @@ -35,13 +35,11 @@ Tests C<LuaFunction> PMC
.sub 'check_HLL'
# .const 'LuaFunction' F1 = 'f1'
.const 'Sub' F1 = 'f1'
$I0 = isa F1, 'LuaFunction'
ok($I0, "check HLL")
isa_ok(F1, 'LuaFunction', "check HLL")
$S0 = F1()
is($S0, "f1()")
.const 'Sub' F2 = 'f2'
$I0 = isa F2, 'LuaFunction'
ok($I0)
isa_ok(F2, 'LuaFunction')
$S0 = F2()
is($S0, "f2()")
.end
Expand All @@ -56,11 +54,9 @@ Tests C<LuaFunction> PMC

.sub 'check_HLL_autoboxing'
$P0 = fct1()
$I0 = isa $P0, 'LuaFunction'
ok($I0, "check HLL autoboxing")
isa_ok($P0, 'LuaFunction', "check HLL autoboxing")
$P0 = fct2()
$I0 = isa $P0, 'LuaFunction'
ok($I0)
isa_ok($P0, 'LuaFunction')
.end

.sub 'fct1'
Expand All @@ -78,24 +74,21 @@ Tests C<LuaFunction> PMC
$S0 = $P0
like($S0, '^function: <[0..9A..Fa..f]>*', "check tostring")
$P1 = $P0.'tostring'()
$I0 = isa $P1, 'LuaString'
ok($I0)
isa_ok($P1, 'LuaString')
$S0 = $P1
like($S0, '^function: <[0..9A..Fa..f]>*')
.end

.sub 'check_tonumber'
$P0 = new 'LuaFunction'
$P1 = $P0.'tonumber'()
$I0 = isa $P1, 'LuaNil'
ok($I0, "check tonumber")
isa_ok($P1, 'LuaNil', "check tonumber")
.end

.sub 'check_init_pmc'
.const 'Sub'F1 = 'f1'
$P0 = new 'LuaFunction', F1
$I0 = isa $P0, 'LuaFunction'
ok($I0, "check init_pmc")
isa_ok($P0, 'LuaFunction', "check init_pmc")
$S0 = $P0()
is($S0, "f1()")
.end
Expand All @@ -108,8 +101,7 @@ Tests C<LuaFunction> PMC
$P1 = get_hll_global '_G'
.const 'LuaString' k_print = 'print'
$P2 = $P1[k_print]
$I0 = isa $P2, 'LuaFunction'
ok($I0, "load from pbc")
isa_ok($P2, 'LuaFunction', "load from pbc")
# $P2($P2)
.end

Expand All @@ -119,8 +111,7 @@ Tests C<LuaFunction> PMC
$P1 = get_hll_global '_G'
.const 'LuaString' k_print = 'print'
$P2 = $P1[k_print]
$I0 = isa $P2, 'LuaFunction'
ok($I0, "load from pbc")
isa_ok($P2, 'LuaFunction', "load from pbc")
# $P2($P2)
.end

Expand Down
3 changes: 1 addition & 2 deletions t/pmc/nil.t
Expand Up @@ -67,8 +67,7 @@ Tests C<LuaNil> PMC
.sub 'check_logical_not'
$P0 = new 'LuaNil'
$P1 = not $P0
$I0 = isa $P1, 'LuaBoolean'
ok($I0, "check logical_not")
isa_ok($P1, 'LuaBoolean', "check logical_not")
$S0 = $P1
is($S0, 'true')
.end
Expand Down
12 changes: 4 additions & 8 deletions t/pmc/nil_hll.t
Expand Up @@ -33,25 +33,22 @@ Tests C<LuaNil> PMC
$P0 = new 'LuaNil'
$S0 = $P0
is($S0, 'nil', "check HLL")
$I0 = isa $P0, 'LuaNil'
ok($I0)
isa_ok($P0, 'LuaNil')
.end

.sub 'check_HLL_const'
.const 'LuaNil' K = 'dummy'
$S0 = K
is($S0, 'nil', "check HLL & .const")
$I0 = isa K, 'LuaNil'
ok($I0)
isa_ok(K, 'LuaNil')
.end

.sub 'check_tostring'
$P0 = new 'LuaNil'
$S0 = $P0
is($S0, 'nil', "check tostring")
$P1 = $P0.'tostring'()
$I0 = isa $P1, 'LuaString'
ok($I0)
isa_ok($P1, 'LuaString')
$S0 = $P1
is($S0, 'nil')
.end
Expand All @@ -61,8 +58,7 @@ Tests C<LuaNil> PMC
$S0 = $P0
is($S0, 'nil', "check tonumber")
$P1 = $P0.'tonumber'()
$I0 = isa $P1, 'LuaNil'
ok($I0)
isa_ok($P1, 'LuaNil')
.end

# Local Variables:
Expand Down
9 changes: 3 additions & 6 deletions t/pmc/number.t
Expand Up @@ -56,13 +56,11 @@ Tests C<LuaNumber> PMC
.sub 'check_set_integer_native'
$P0 = new 'LuaNumber'
set $P0, 3.14
$I0 = isa $P0, 'LuaNumber'
ok($I0, "check set_integer_native")
isa_ok($P0, 'LuaNumber', "check set_integer_native")
$N0 = $P0
is($N0, 3.14)
set $P0, 2
$I0 = isa $P0, 'LuaNumber'
ok($I0)
isa_ok($P0, 'LuaNumber')
$N0 = $P0
is($N0, 2)
.end
Expand All @@ -71,8 +69,7 @@ Tests C<LuaNumber> PMC
$P0 = new 'LuaNumber'
set $P0, 3.14
$P1 = not $P0
$I0 = isa $P1, 'LuaBoolean'
ok($I0, "check logical_not")
isa_ok($P1, 'LuaBoolean', "check logical_not")
$S0 = $P1
is($S0, 'false')
.end
Expand Down
21 changes: 7 additions & 14 deletions t/pmc/number_hll.t
Expand Up @@ -37,16 +37,14 @@ Tests C<LuaNumber> PMC
set $P0, 3.14
$N0 = $P0
is($N0, 3.14, "check HLL")
$I0 = isa $P0, 'LuaNumber'
ok($I0)
isa_ok($P0, 'LuaNumber')
.end

.sub 'check_HLL_autoboxing'
$P0 = fct()
$N0 = $P0
is($N0, 3.14, "check HLL autoboxing")
$I0 = isa $P0, 'LuaNumber'
ok($I0)
isa_ok($P0, 'LuaNumber')
.end

.sub 'fct' :anon
Expand All @@ -57,24 +55,21 @@ Tests C<LuaNumber> PMC
.const 'LuaNumber' K = '3.14'
$N0 = K
is($N0, 3.14, "check HLL & .const")
$I0 = isa K, 'LuaNumber'
ok($I0)
isa_ok(K, 'LuaNumber')
.end

.sub 'check_box_float'
$P0 = box 3.14
$N0 = $P0
is($N0, 3.14, "check box float")
$I0 = isa $P0, 'LuaNumber'
ok($I0)
isa_ok($P0, 'LuaNumber')
.end

.sub 'check_box_integer'
$P0 = box -2
$N0 = $P0
is($N0, -2, "check box integer")
$I0 = isa $P0, 'LuaNumber'
ok($I0)
isa_ok($P0, 'LuaNumber')
.end

.sub 'check_tostring'
Expand All @@ -83,8 +78,7 @@ Tests C<LuaNumber> PMC
$N0 = $P0
is($N0, 3.14, "check tostring")
$P1 = $P0.'tostring'()
$I0 = isa $P1, 'LuaString'
ok($I0)
isa_ok($P1, 'LuaString')
$S0 = $P1
is($S0, '3.14')
.end
Expand All @@ -95,8 +89,7 @@ Tests C<LuaNumber> PMC
$N0 = $P0
is($N0, 3.14, "check tonumber")
$P1 = $P0.'tonumber'()
$I0 = isa $P1, 'LuaNumber'
ok($I0)
isa_ok($P1, 'LuaNumber')
$N0 = $P1
is($N0, 3.14)
.end
Expand Down
3 changes: 1 addition & 2 deletions t/pmc/string.t
Expand Up @@ -68,8 +68,7 @@ Tests C<LuaString> PMC
$P0 = new 'LuaString'
set $P0, 'str'
$P1 = not $P0
$I0 = isa $P1, 'LuaBoolean'
ok($I0, "check logical_not")
isa_ok($P1, 'LuaBoolean', "check logical_not")
$S0 = $P1
is($S0, 'false')
.end
Expand Down
24 changes: 8 additions & 16 deletions t/pmc/string_hll.t
Expand Up @@ -39,16 +39,14 @@ Tests C<LuaString> PMC
set $P0, "simple string"
$S0 = $P0
is($S0, "simple string", "check HLL")
$I0 = isa $P0, 'LuaString'
ok($I0)
isa_ok($P0, 'LuaString')
.end

.sub 'check_HLL_autoboxing'
$P0 = fct()
$S0 = $P0
is($S0, "simple string", "check HLL autoboxing")
$I0 = isa $P0, 'LuaString'
ok($I0)
isa_ok($P0, 'LuaString')
.end

.sub 'fct' :anon
Expand All @@ -59,24 +57,21 @@ Tests C<LuaString> PMC
.const 'LuaString' K = "simple string"
$S0 = K
is($S0, "simple string", "check HLL & .const")
$I0 = isa K, 'LuaString'
ok($I0)
isa_ok(K, 'LuaString')
.end

.sub 'check_empty_string'
.const 'LuaString' K = ''
$S0 = K
is($S0, '', "check empty string")
$I0 = isa K, 'LuaString'
ok($I0)
isa_ok(K, 'LuaString')
.end

.sub 'check_box'
$P0 = box "simple string"
$S0 = $P0
is($S0, "simple string", "check box")
$I0 = isa $P0, 'LuaString'
ok($I0)
isa_ok($P0, 'LuaString')
.end

.sub 'check_is_equal'
Expand All @@ -94,8 +89,7 @@ Tests C<LuaString> PMC
$S0 = $P0
is($S0, 'value', "check tostring")
$P1 = $P0.'tostring'()
$I0 = isa $P1, 'LuaString'
ok($I0)
isa_ok($P1, 'LuaString')
$S0 = $P1
is($S0, 'value')
.end
Expand All @@ -106,8 +100,7 @@ Tests C<LuaString> PMC
$S0 = $P0
is($S0, '3.14', "check tonumber")
$P1 = $P0.'tonumber'()
$I0 = isa $P1, 'LuaNumber'
ok($I0)
isa_ok($P1, 'LuaNumber')
$N0 = $P1
is($N0, 3.14)
.end
Expand All @@ -118,8 +111,7 @@ Tests C<LuaString> PMC
$S0 = $P0
is($S0, '111', "check tobase")
$P1 = $P0.'tobase'(2)
$I0 = isa $P1, 'LuaNumber'
ok($I0)
isa_ok($P1, 'LuaNumber')
$I0 = $P1
is($I0, 7)
.end
Expand Down
3 changes: 1 addition & 2 deletions t/pmc/table.t
Expand Up @@ -72,8 +72,7 @@ Tests C<table> type
.sub 'check_logical_not'
$P0 = new 'LuaTable'
$P1 = not $P0
$I0 = isa $P1, 'LuaBoolean'
ok($I0, "check logical_not")
isa_ok($P1, 'LuaBoolean', "check logical_not")
$S0 = $P1
is($S0, 'false')
.end
Expand Down
9 changes: 3 additions & 6 deletions t/pmc/table_hll.t
Expand Up @@ -32,8 +32,7 @@ Tests C<table> type

.sub 'check_HLL'
$P0 = new 'LuaTable'
$I0 = isa $P0, 'LuaTable'
ok($I0, "check HLL")
isa_ok($P0, 'LuaTable', "check HLL")
.end

.sub 'check_len'
Expand Down Expand Up @@ -120,17 +119,15 @@ Tests C<table> type
$S0 = $P0
like($S0, '^table: <[0..9A..Fa..f]>*', "check tostring")
$P1 = $P0.'tostring'()
$I0 = isa $P1, 'LuaString'
ok($I0)
isa_ok($P1, 'LuaString')
$S0 = $P1
like($S0, '^table: <[0..9A..Fa..f]>*')
.end

.sub 'check_tonumber'
$P0 = new 'LuaTable'
$P1 = $P0.'tonumber'()
$I0 = isa $P1, 'LuaNil'
ok($I0, "check tonumber")
isa_ok($P1, 'LuaNil', "check tonumber")
.end

# Local Variables:
Expand Down

0 comments on commit 097b717

Please sign in to comment.