-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathSetReplaceFixedPoint.wlt
More file actions
101 lines (79 loc) · 2.64 KB
/
Copy pathSetReplaceFixedPoint.wlt
File metadata and controls
101 lines (79 loc) · 2.64 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
<|
"SetReplaceFixedPoint" -> <|
"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[
SetReplaceFixedPoint[Range[1000], {a_, b_} :> {a + b}]
],
(* Argument Checks *)
(** Argument count **)
testUnevaluated[
SetReplaceFixedPoint[{1}],
{SetReplaceFixedPoint::argr}
],
testUnevaluated[
SetReplaceFixedPoint[{1}, {1 -> 2}, 3],
{SetReplaceFixedPoint::argrx}
],
(** Set is a list **)
testUnevaluated[
SetReplaceFixedPoint[1, 1 -> 2],
{SetReplaceFixedPoint::setNotList}
],
(** Rules are valid **)
testUnevaluated[
SetReplaceFixedPoint[{1}, {1}],
{SetReplaceFixedPoint::invalidRules}
],
(** Options are valid **)
testUnevaluated[
SetReplaceFixedPoint[{1, 1, 1}, {1 -> 2}, # -> 123],
{SetReplaceFixedPoint::optx}
] & /@ {"$$$InvalidOption###", "EventSelectionFunction"},
(* Implementation *)
VerificationTest[
SetReplaceFixedPoint[{1, 1, 1}, {1 -> 2}],
{2, 2, 2}
],
VerificationTest[
SetReplaceFixedPoint[{{1, 2}, {2, 3}, {3, 4}}, {{a_, b_}, {b_, c_}} :> {{a, c}}],
{{1, 4}}
],
VerificationTest[
SetReplaceFixedPoint[{{1, 2}, {2, 3}, {3, 1}}, {{a_, b_}, {b_, c_}} :> {{a, c}}, Method -> "Symbolic"],
{{3, 3}}
],
VerificationTest[
SetReplaceFixedPoint[{{1, 2}, {2, 3}, {3, 1}}, {{a_, b_}, {b_, c_}} :> {{a, c}}, Method -> "LowLevel"],
{{3, 3}}
],
VerificationTest[
SetReplaceFixedPoint[{{1, 2}, {2, 3}, {3, 4}}, {{a_, b_}} :> {}],
{}
],
VerificationTest[
TimeConstrained[SetReplaceFixedPoint[{}, {} :> {{1, 2}}], 1],
$Aborted
],
VerificationTest[
TimeConstrained[SetReplaceFixedPoint[{{1, 2}}, {{1, 2}} :> {{1, 2}}], 1],
$Aborted
],
(* TimeConstraint *)
VerificationTest[
SetReplaceFixedPoint[
{{0, 0}}, ToPatternRules[{{1, 2}} -> {{1, 3}, {3, 2}}], Method -> #, TimeConstraint -> 0.1],
$Aborted
] & /@ $SetReplaceMethods,
VerificationTest[
TimeConstrained[SetReplaceFixedPoint[{{0, 0}}, ToPatternRules[{{1, 2}} -> {{1, 3}, {3, 2}}], Method -> #], 0.1],
$Aborted
] & /@ $SetReplaceMethods
}
|>
|>