2 # Copyright (C) 2008-2010, Parrot Foundation.
7 t/op/string-mem.t - test memory representation related string operations
12 % prove t/op/string_mem.t
16 Tests string ops related to low-level representation of strings, such as:
32 .include 'stringinfo.pasm'
33 .include 'interpinfo.pasm'
38 .include 'test_more.pir'
43 $S0 = interpinfo .INTERPINFO_GC_SYS_NAME
44 if $S0 == "inf" goto dont_run_hanging_tests
47 dont_run_hanging_tests:
48 ok(1, "#TODO - Test disabled on gc_inf")
49 ok(1, "#TODO - Test disabled on gc_inf")
57 $I0 = stringinfo $S0, .STRINGINFO_STRSTART
58 $I1 = stringinfo $S1, .STRINGINFO_STRSTART
59 is($I0, $I1, "stringinfo - test STRSTART can see COW in action")
61 $I0 = stringinfo $S0, .STRINGINFO_HEADER
62 $I1 = stringinfo $S1, .STRINGINFO_HEADER
63 is($I0, $I1, "stringinfo - STRHEADER on full COW strings keeps same value")
66 is($S2, "world", "sanity check")
67 $I4 = stringinfo $S0, .STRINGINFO_STRSTART
68 $I2 = stringinfo $S2, .STRINGINFO_STRSTART
70 is($I3, 7, "stringinfo - STRSTART can see COW in action")
72 $I2 = stringinfo $S2, .STRINGINFO_HEADER
73 isnt($I0, $I2, "stringinfo - STRHEADER on different COW strings same value")
78 .local int init, before, after
102 init = stringinfo $S6, .STRINGINFO_STRSTART
104 $I0 = interpinfo .INTERPINFO_GC_COLLECT_RUNS
107 $I1 = interpinfo .INTERPINFO_GC_COLLECT_RUNS
110 before = stringinfo $S6, .STRINGINFO_STRSTART
113 $I0 = interpinfo .INTERPINFO_GC_COLLECT_RUNS
116 $I1 = interpinfo .INTERPINFO_GC_COLLECT_RUNS
119 after = stringinfo $S6, .STRINGINFO_STRSTART
121 is( init, before, "pin/collect didn't change memory address" )
122 $I0 = cmp after, before
135 ok( $I0, "location of string changed by unpin/collect" )
138 #.constant STRINGINFO_STRSTART 2
139 #.constant STRINGINFO_BUFLEN 3
140 #.constant STRINGINFO_FLAGS 4
141 #.constant STRINGINFO_BUFUSED 5
142 #.constant STRINGINFO_STRLEN 6
148 # vim: expandtab shiftwidth=4 ft=pir: