2 # Copyright (C) 2001-2010, Parrot Foundation.
7 t/pmc/env.t - System Environment
20 .include 'test_more.pir'
23 all_envs_are_identical()
25 all_envs_are_the_same()
34 .sub all_envs_are_identical
38 ok(0, "all Envs aren't identical")
41 ok(1, "all Envs are identical")
47 set $P0['PARROT_TMP'], 'hello polly'
48 set $S0, $P0['PARROT_TMP']
49 is($S0, 'hello polly', 'getenv and setenv work with string keys')
50 delete $P0['PARROT_TMP']
59 is($P3, "Foobar", "getenv and setenv work with PMC keys")
60 delete $P0['PARROT_TMP']
63 is($S0, '', 'getenv works with a null key')
66 .sub all_envs_are_the_same
68 set $P0['PARROT_TMP'], 'hello polly'
69 set $S0, $P0['PARROT_TMP']
71 set $S1, $P1['PARROT_TMP']
72 is($S0, $S1, 'all envs are the same')
73 delete $P0['PARROT_TMP']
78 set $P0['PARROT_TMP'], 'hello polly'
79 exists $I0, $P0['PARROT_TMP']
81 ok(0, "expected element doesn't exist")
83 ok(1, 'expected element exists')
84 delete $P0['PARROT_TMP']
85 set $S0, $P0['PARROT_TMP']
87 ok(0, 'deleted element exists')
89 ok(1, 'deleted element is deleted')
94 set $P0["PARROT_1"], "hello"
95 set $P0["PARROT_2"], "polly"
101 eq $S2, "PARROT_1", gotit
102 eq $S2, "PARROT_2", gotit
109 is($I0, 2, 'assigned env vars showed up in the iterator')
112 # This will not work on our unsetenv implementation
113 #skip( "no native unsetenv", 1 ) unless $PConfig{"unsetenv"};
116 .include "iglobals.pasm"
117 .local pmc config_hash, interp
119 config_hash = interp[.IGLOBALS_CONFIG_HASH]
120 $I0 = config_hash["unsetenv"]
122 unless $I0 goto no_unsetenv
125 set $P0['PARROT_TMP'], 'hello polly'
126 exists $I0, $P0['PARROT_TMP']
127 ok( $I0, "set env var stays set")
128 delete $P0["PARROT_TMP"]
129 exists $I0, $P0["PARROT_TMP"]
130 is($I0, 0, "deleted env var stays deleted")
134 skip(1, "no native unsetenv")
135 skip(1, "no native unsetenv")
139 .sub is_interface_done
144 does bool1, pmc1, 'hash'
145 ok(bool1, 'does Hash')
147 does bool1, pmc1, 'scalar'
148 is(bool1, 0, "doesn't do Scalar")
150 does bool1, pmc1, 'no_interface'
151 is(bool1, 0, "doesn't do no_interface")
156 .local int int_before, int_after, int_diff
157 .local num num_before, num_after, num_diff
159 # add three more keys in env
163 env["PARROT_TMP_ADD_1"] = "tmp_add_1"
164 env["PARROT_TMP_ADD_2"] = "tmp_add_2"
165 env["PARROT_TMP_ADD_3"] = "tmp_add_3"
168 num_diff = num_after - num_before
169 int_diff = int_after - int_before
170 is(int_diff, 3, "get_integer seems sane")
171 is(num_diff, 3, "get_number seems sane")
173 #clean up the environment
174 delete env['PARROT_TMP_ADD_1']
175 delete env['PARROT_TMP_ADD_2']
176 delete env['PARROT_TMP_ADD_3']
182 is($S0, '', 'no segfault')
189 # vim: expandtab shiftwidth=4 ft=pir: