aboutsummaryrefslogtreecommitdiffhomepage
path: root/system/system.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-09-03 02:16:10 +0900
committerOphestra <cat@gensokyo.uk>2025-09-03 02:16:10 +0900
commit024d2ff7826a81db65eefa1843730b537ebdeef1 (patch)
treeb3d9048c075fec0759bd8886a07a252ca0ce4555 /system/system.go
parent6f719bc3c19d56279d2d76d3bcf8fb66ace2d2fb (diff)
system: improve tests of the I struct
This cleans up for the test overhaul of this package. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'system/system.go')
-rw-r--r--system/system.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/system/system.go b/system/system.go
index e8fa43fa..1a653636 100644
--- a/system/system.go
+++ b/system/system.go
@@ -20,13 +20,13 @@ const (
// Criteria specifies types of Op to revert.
type Criteria Enablement
-func (ec *Criteria) hasType(o Op) bool {
+func (ec *Criteria) hasType(t Enablement) bool {
// nil criteria: revert everything except User
if ec == nil {
- return o.Type() != User
+ return t != User
}
- return Enablement(*ec)&o.Type() != 0
+ return Enablement(*ec)&t != 0
}
// Op is a reversible system operation.
@@ -92,7 +92,7 @@ func (sys *I) UID() int { return sys.uid }
// Equal returns whether all [Op] instances held by sys matches that of target.
func (sys *I) Equal(target *I) bool {
- if target == nil || sys.uid != target.uid || len(sys.ops) != len(target.ops) {
+ if sys == nil || target == nil || sys.uid != target.uid || len(sys.ops) != len(target.ops) {
return false
}
@@ -149,7 +149,6 @@ func (sys *I) Revert(ec *Criteria) error {
// collect errors
errs := make([]error, len(sys.ops))
-
for i := range sys.ops {
errs[i] = sys.ops[len(sys.ops)-i-1].revert(sys, ec)
}