-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy path_SeededRandomness.gen.m
More file actions
64 lines (48 loc) · 1.55 KB
/
_SeededRandomness.gen.m
File metadata and controls
64 lines (48 loc) · 1.55 KB
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
%% ¡header!
SeededRandomness < ConcreteElement (sr, randomizer) generates a random number.
%%% ¡description!
A Randomizer (SeededRandomness) is an element with a random result property
whose main purpose is to illustrate the use of seeded randomness.
%% ¡props_update!
%%% ¡prop!
ELCLASS (constant, string) is the class of the randomizer.
%%%% ¡default!
'SeededRandomness'
%%% ¡prop!
NAME (constant, string) is the name of the randomizer.
%%%% ¡default!
'Randomizer'
%%% ¡prop!
DESCRIPTION (constant, string) is the description of the randomizer.
%%%% ¡default!
'A Randomizer (SeededRandomness) is an element with a random result property whose main purpose is to illustrate the use of seeded randomness.'
%%% ¡prop!
TEMPLATE (parameter, item) is the template of the randomizer.
%%%% ¡settings!
'SeededRandomness'
%%% ¡prop!
ID (data, string) is a few-letter code for the randomizer.
%%%% ¡default!
'SeededRandomness ID'
%%% ¡prop!
LABEL (metadata, string) is an extended label of the randomizer.
%%%% ¡default!
'SeededRandomness label'
%%% ¡prop!
NOTES (metadata, string) are some specific notes about the randomizer.
%%%% ¡default!
'SeededRandomness notes'
%% ¡props!
%%% ¡prop!
RANDOM_NUMBER (result, scalar) is a random number.
%%%% ¡calculate!
value = rand();
%% ¡tests!
%%% ¡test!
Simple test
%%%% ¡code!
sr1 = SeededRandomness()
sr2 = SeededRandomness()
assert(sr1.get('RANDOM_NUMBER') == sr1.get('RANDOM_NUMBER'))
assert(sr2.get('RANDOM_NUMBER') == sr2.get('RANDOM_NUMBER'))
assert(sr1.get('RANDOM_NUMBER') ~= sr2.get('RANDOM_NUMBER'))