File: testsuite_map_include.kbs

package info (click to toggle)
basic256 2.0.99.10-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,888 kB
  • sloc: cpp: 17,185; yacc: 4,025; lex: 1,466; java: 1,091; sh: 39; xml: 33; makefile: 20
file content (100 lines) | stat: -rw-r--r-- 2,261 bytes parent folder | download | duplicates (2)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# testsuite_map_include section for BASIC256

# Modification History
# date		programmer	description
# 20200423	j.m.reneau	split from testsuite

currentsuite = "map"

map q
q['q'] = 'QQ'
q['a'] = "AA"
q['b'] = "BB"


call s("set key a on map q", q['a'], "AA")
call s("set key b on map q", q['b'], "BB")
call s("set key q on map q", q['q'], "QQ")

call n("map should have three items - length", length(q), 3)
call n("map should have three items - ?", q[?], 3)

## order should be in string sort order
total = ""
for each i in q
	total = total + q[i]
	? i,q[i],total
next i
call s("in alpha order", total, "AABBQQ")


q['n'] = 99
q['m'] = 99
q['sum'] = q['m'] + q['n']
call n("normal math with map elements", q['sum'], 198)

call n("map should have six items - length", length(q), 6)

call boolean("key x - not exist ? ", typeof(q['x'])=TYPE_UNASSIGNED)
call boolean("key a - exist ? ", typeof(q['a'])<>TYPE_UNASSIGNED)
call boolean("key x - not assigned ", not assigned(q['x']))
call boolean("key a - assigned ", assigned(q['a']))



unassign q['a']
total = ""
for each i in q
	total = total + q[i]
	? i,q[i],total
next i
call s("in alpha order after delete ", total, "BB9999QQ198")

call n("after unassign - map should have 5 items - length", length(q), 5)
call boolean("key a - not exist ? ", typeof(q['a'])=TYPE_UNASSIGNED)
call boolean("key a - not assigned ", not assigned(q['a']))

sq = serialize(q)
? sq

qq = unserialize(sq)
call n("unserialize - length",length(q), length(qq))
for each i in qq
	print i, q[i], qq[i]
	call s("unserialize key ";i;" same",q[i],qq[i])
	call n("unserialize key ";i;" type same",typeof(q[i]),typeof(qq[i]))
next i

unassign q
unassign qq	


a = {'a'->'alpha','b'->"bravo",'c'->"charlie",'d'->'delta'}
total = ''
foreach k in a
	total = total ; k
	? k
next 
call s("brace build variable", total, "abcd")

total = ''
foreach k->v in a
	total = total ; k; v
	? k,v
next 
call s("foreach key and value", total, "aalphabbravoccharlieddelta")

total = ''
foreach k in {1->'x','x'->1,2->'y','y'->2}
	total = total ; k
	? k
next 
call s("brace build for each", total, "12xy")

total = ''
foreach k->v in  {1->'x','x'->1,2->'y','y'->2}
	total = total ; k; v
	? k,v
next 
call s("brace build foreach key and value", total, "1x2yx1y2")