Skip to content

Commit ea391b0

Browse files
committed
Closes #33
1 parent f777a9c commit ea391b0

File tree

8 files changed

+42
-5
lines changed

8 files changed

+42
-5
lines changed

Src/Certainties/Loop.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public static bool operator true (loop s)
3434
public static bool operator false (loop s)
3535
=> throw new InvOp("falsehood cannot be tested (loop)");
3636

37+
public override bool Equals(object x) => x is loop;
38+
3739
override public int GetHashCode() => 0;
3840

3941
public static implicit operator impending(loop self)

Src/Logging/StatusLogging.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ partial struct status{
2222
? new status(this, new LogTrace(trace.scope, trace.next, reason))
2323
: this;
2424

25+
[Obsolete("Use via Active.Raw or Active.Status", false)]
2526
public static status ε(status s, [P] S path="", [M] S member="",
2627
[L] int line=0)
2728
=> Eval(s, path, member, line);
2829

30+
[Obsolete("Use via Active.Status or Active.Raw", false)]
2931
public static status Eval(status s, [P] S path="", [M] S member="",
3032
[L] int line=0)
3133
=> log ? Lg.Status(s, null, path, member, line) : s;

Src/Static/Raw.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,8 @@ public static class Raw{
1717

1818
public static status Eval(status s) => s;
1919

20+
public static action Do (object arg) => @void;
21+
public static loop Cont (object arg) => forever;
22+
public static failure Fail (object arg) => @false;
23+
2024
}}

Src/Static/Status.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ public static class Status{
3131

3232
public static status ε(status s) => s;
3333

34+
public static action Do (object arg) => action._done;
35+
public static loop Cont (object arg) => loop._cont;
36+
public static failure Fail (object arg) => failure._fail;
37+
3438
#else // logging variants ======================================
3539

3640
internal static bool log => status.log;
@@ -66,6 +70,18 @@ public static status Eval(status s,
6670
[P] S path="", [M] S member="", [L] int line=0)
6771
=> status.log ? Lg.Status(s, null, path, member, line) : s;
6872

73+
public static action Do(object arg,
74+
[P] S path="", [M] S member="", [L] int line=0)
75+
=> status.log ? Lg.Action(null, path, member, line) : action._done;
76+
77+
public static loop Cont(object arg,
78+
[P] S path="", [M] S member="", [L] int line=0)
79+
=> status.log ? Lg.Forever(null, path, member, line) : loop._cont;
80+
81+
public static failure Fail(object arg,
82+
[P] S path="", [M] S member="", [L] int line=0)
83+
=> status.log ? Lg.Failure(null, path, member, line) : failure._fail;
84+
6985
public static status ε(status s, [P] S path="", [M] S member="",
7086
[L] int line=0)
7187
=> Eval(s, path, member, line);

Src/Status.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public status Map(in status failTo, in status contTo,
6363
public status ViaDecorator(IDecorator scope, S reason=null)
6464
=> this;
6565

66-
[Obsolete("Import Active.Status/Active.Raw", false)]
66+
[Obsolete("Use via Active.Status or Active.Raw", false)]
6767
public static status Eval(status s) => s;
6868

6969
public static status done(S reason = null) => _done;

Tests/TestRawSemantics.cs renamed to Tests/TestActiveRaw.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using Active.Core;
33
using static Active.Raw;
44

5-
public class TestRawSemantics : TestBase{
5+
public class TestActiveRaw : TestBase{
66

77
[Test] public void Standard(){
88
o( done.complete );
@@ -39,4 +39,8 @@ [Test] public void Eval_([Range(-1, 1)] int val){
3939
o( s0, Eval(s0) );
4040
}
4141

42+
[Test] public void Do_ () => o( Do(null), @void );
43+
[Test] public void Cont_() => o( Cont(null), forever );
44+
[Test] public void Fail_() => o( Fail(null), @false );
45+
4246
}

Tests/TestStatusStaticImport.cs renamed to Tests/TestActiveStatus.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using Active.Core;
33
using static Active.Status;
44

5-
public class TestStatusStaticImport : TestBase{
5+
public class TestActiveStatus : TestBase{
66

77
bool _log;
88
[SetUp] public void SaveLoggingState() => _log = status.log;
@@ -50,4 +50,13 @@ [Test] public void ε_([Range(-1, 1)] int val){
5050
o( s0, ε(s0) );
5151
}
5252

53+
[Test] public void Do_ ([Values(true, false)] bool lg)
54+
{ status.log = lg; o( Do(null), @void() ); }
55+
56+
[Test] public void Cont_([Values(true, false)] bool lg)
57+
{ status.log = lg; o( Cont(null), forever() ); }
58+
59+
[Test] public void Fail_([Values(true, false)] bool lg)
60+
{ status.log = lg; o( Fail(null), @false() ); }
61+
5362
}

Tests/TestStatus.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ [Test] public void Condoner_withTrace(){
160160

161161
// SCHEDULED FOR DEPRECATION ====================================
162162

163+
#pragma warning disable 618
164+
163165
#if !AL_OPTIMIZE
164166

165167
[Test] public void Eval_ε([Values(true, false)] bool lg){
@@ -175,8 +177,6 @@ [Test] public void Eval_ε([Values(true, false)] bool lg){
175177

176178
#endif
177179

178-
#pragma warning disable 618
179-
180180
[Test] public void Eval(){
181181

182182
o( status.Eval(done).complete );

0 commit comments

Comments
 (0)