-
Notifications
You must be signed in to change notification settings - Fork 138
/
uuid.t
129 lines (99 loc) · 2.85 KB
/
uuid.t
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!./parrot
# Copyright (C) 2008-2010, Parrot Foundation.
=head1 NAME
t/library/uuid.t
=head1 SYNOPSIS
% prove t/library/uuid.t
=head1 DESCRIPTION
uuid library tests
=cut
.sub main :main
load_bytecode 'uuid.pbc'
.include 'test_more.pir'
plan(20)
test_generate_1()
test_generate_2()
test_generate_random()
test_generate_time()
test_parse_1()
test_parse_2()
test_time()
test_type()
test_variant()
.end
.sub test_generate_1
$P0 = get_global ['uuid'], 'generate'
$P1 = $P0()
$S1 = typeof $P1
is($S1,'uuid', 'generate 1')
.end
.sub test_generate_2
$P0 = get_global ['uuid'], 'generate'
$P1 = $P0()
like($P1, '<[0..9a..f]>**8\-<[0..9a..f]>**4\-<[0..9a..f]>**4\-<[0..9a..f]>**4\-<[0..9a..f]>**12', 'generate 2' )
.end
.sub test_generate_random
$P0 = get_global ['uuid'], 'generate_random'
$P1 = $P0()
like($P1, '<[0..9a..f]>**8\-<[0..9a..f]>**4\-<[0..9a..f]>**4\-<[0..9a..f]>**4\-<[0..9a..f]>**12', 'generate random')
.end
.sub test_generate_time
$P0 = get_global ['uuid'], 'generate_time'
$P1 = $P0()
like($P1, '<[0..9a..f]>**8\-<[0..9a..f]>**4\-<[0..9a..f]>**4\-<[0..9a..f]>**4\-<[0..9a..f]>**12', 'generate time')
.end
.sub test_parse_1
$P0 = get_global ['uuid'], 'parse'
($I0, $P1) = $P0("84949cc5-4701-4a84-895b-354c584a981b")
is($I0, 0, 'parse 1')
$S1 = typeof $P1
is($S1, 'uuid', 'parse 1')
.end
.sub test_parse_2
$P0 = get_global ['uuid'], 'parse'
$I0 = $P0("84949cc5-4701-4a84-895b-354c584a981b")
is($I0, 0, 'parse 2')
$I0 = $P0("84949CC5-4701-4A84-895B-354C584A981B")
is($I0, 0, 'parse 2')
$I0 = $P0("84949cc5-4701-4a84-895b-354c584a981bc")
is($I0, -1, 'parse 2')
$I0 = $P0("84949cc5-4701-4a84-895b-354c584a981")
is($I0, -1, 'parse 2')
$I0 = $P0("84949cc5x4701-4a84-895b-354c584a981b")
is($I0, -1, 'parse 2')
$I0 = $P0("84949cc504701-4a84-895b-354c584a981b")
is($I0, -1, 'parse 2')
$I0 = $P0("84949cc5-470104a84-895b-354c584a981b")
is($I0, -1, 'parse 2')
$I0 = $P0("84949cc5-4701-4a840895b-354c584a981b")
is($I0, -1, 'parse 2')
$I0 = $P0("84949cc5-4701-4a84-895b0354c584a981b")
is($I0, -1, 'parse 2')
$I0 = $P0("g4949cc5-4701-4a84-895b-354c584a981b")
is($I0, -1, 'parse 2')
$I0 = $P0("84949cc5-4701-4a84-895b-354c584a981g")
is($I0, -1, 'parse 2')
.end
.sub test_time
$P0 = get_global ['uuid'], 'parse'
($I0, $P1) = $P0("84949cc5-4701-4a84-895b-354c584a981b")
$I1 = $P1.'time'()
is($I1, -1, 'time')
.end
.sub test_type
$P0 = get_global ['uuid'], 'generate'
$P1 = $P0()
$I0 = $P1.'type'()
is($I0, 4, 'type')
.end
.sub test_variant
$P0 = get_global ['uuid'], 'generate'
$P1 = $P0()
$I0 = $P1.'variant'()
is($I0, 1, 'variant')
.end
# Local Variables:
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir: