aUCBLogo Demos and Tests / testscope
ct
be p1
local [::a]
a=2
pr a
b=3
p2
end
be p2
be p3
pr b
end
pr a
; pr p1::b
; local [p1::b]
b=4
p3
; p5 &b
end
be p3 &var2
p4 &var2
end
be p4 &var3
var3=var3+1
end
be p5 &var1
p3 &var1
pr var1
end
be testscope
; ct
;traceall
; threadtest
; ::a=1 ;global
; p1
; p2
; p5 &a
; pr a
; a=1
be p6 b
be p7 c
be p8 d
local [e]
e=c+2
pr :e
pr d
pr c
pr b
a=a+10
pr a
end
p8 c+1
c=c+111
end
p7 b+1
end
; p6 a+1
be p11 b
be p12 c
output b+c
end
output a+p12 3
end
be p2
be p3
pr x
end
end
; ::p2::p3::b=27
; ::p2::p3
; ::ok=0
; ::check [:a] 1
; p13
; p14
; local [a]
; a=1
; b=2
; p9 &a &b
p15
end
be p13
b=2
check [:b] 2
end
be p14
check [false] true
end
be p9 &b &c
p10 &b &c
end
be p10 &a &b
pr a
pr b
end
be p15
be p16 b
a=b
pr a
end
local [a b]
a=15
p17 17
pr a
end
be p17 b
local [c]
c=18
p15::p16 b
end
be threadtest
; localmake "a 123
be p1 i j
pr i
(GC true)
if i>j [p1 i-1 j]
pr i
end
be t1 :i
pr 5 p1 3+:i*100 :i*100+1 pr 6
end
repeat 10
[
thread (se [pr 5 p1] 3+repcount*10 repcount*10+1 [pr 6])
thread list "t1 repcount
gc
]
thread [pr 5 p1 13 11 pr 6]
; p1 3 1
end