-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathSetReplaceFixedPointList.wlt
More file actions
102 lines (80 loc) · 2.96 KB
/
Copy pathSetReplaceFixedPointList.wlt
File metadata and controls
102 lines (80 loc) · 2.96 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
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
<|
"SetReplaceFixedPointList" -> <|
"init" -> (
Attributes[Global`testUnevaluated] = Attributes[Global`testSymbolLeak] = {HoldAll};
Global`testUnevaluated[args___] := SetReplace`PackageScope`testUnevaluated[VerificationTest, args];
Global`testSymbolLeak[args___] := SetReplace`PackageScope`testSymbolLeak[VerificationTest, args];
),
"tests" -> {
(* Symbol Leak *)
testSymbolLeak[
SetReplaceFixedPointList[Range[100], {a_, b_} :> {a + b}]
],
(* Argument Checks *)
(** Argument count **)
testUnevaluated[
SetReplaceFixedPointList[{1}],
{SetReplaceFixedPointList::argr}
],
testUnevaluated[
SetReplaceFixedPointList[{1}, {1 -> 2}, 3],
{SetReplaceFixedPointList::argrx}
],
(** Set is a list **)
testUnevaluated[
SetReplaceFixedPointList[1, 1 -> 2],
{SetReplaceFixedPointList::setNotList}
],
(** Rules are valid **)
testUnevaluated[
SetReplaceFixedPointList[{1}, {1}],
{SetReplaceFixedPointList::invalidRules}
],
(** Options are valid **)
testUnevaluated[
SetReplaceFixedPointList[{1, 1, 1}, {1 -> 2}, # -> 123],
{SetReplaceFixedPointList::optx}
] & /@ {"$$$InvalidOption###", "EventSelectionFunction"},
(* Implementation *)
VerificationTest[
SetReplaceFixedPointList[{1, 1, 1}, {1 -> 2}],
{{1, 1, 1}, {1, 1, 2}, {1, 2, 2}, {2, 2, 2}}
],
VerificationTest[
SetReplaceFixedPointList[{{1, 2}, {2, 3}, {3, 4}}, {{a_, b_}, {b_, c_}} :> {{a, c}}],
{{{1, 2}, {2, 3}, {3, 4}}, {{3, 4}, {1, 3}}, {{1, 4}}}
],
VerificationTest[
SetReplaceFixedPointList[{{1, 2}, {2, 3}, {3, 1}}, {{a_, b_}, {b_, c_}} :> {{a, c}}, Method -> "LowLevel"],
{{{1, 2}, {2, 3}, {3, 1}}, {{3, 1}, {1, 3}}, {{3, 3}}}
],
VerificationTest[
SetReplaceFixedPointList[{{1, 2}, {2, 3}, {3, 1}}, {{a_, b_}, {b_, c_}} :> {{a, c}}, Method -> "Symbolic"],
{{{1, 2}, {2, 3}, {3, 1}}, {{3, 1}, {1, 3}}, {{3, 3}}}
],
VerificationTest[
SetReplaceFixedPointList[{{1, 2}, {2, 3}, {3, 4}}, {{a_, b_}} :> {}],
{{{1, 2}, {2, 3}, {3, 4}}, {{2, 3}, {3, 4}}, {{3, 4}}, {}}
],
VerificationTest[
TimeConstrained[SetReplaceFixedPointList[{}, {} :> {{1, 2}}], 1],
$Aborted
],
VerificationTest[
TimeConstrained[SetReplaceFixedPointList[{{1, 2}}, {{1, 2}} :> {{1, 2}}], 1],
$Aborted
],
(* TimeConstraint *)
VerificationTest[
SetReplaceFixedPointList[
{{0, 0}}, ToPatternRules[{{1, 2}} -> {{1, 3}, {3, 2}}], Method -> #, TimeConstraint -> 0.1],
$Aborted
] & /@ $SetReplaceMethods,
VerificationTest[
TimeConstrained[
SetReplaceFixedPointList[{{0, 0}}, ToPatternRules[{{1, 2}} -> {{1, 3}, {3, 2}}], Method -> #], 0.1],
$Aborted
] & /@ $SetReplaceMethods
}
|>
|>