• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mlange-42 / ark-tools / 13609263776

01 Mar 2025 10:08PM CUT coverage: 100.0%. First build
13609263776

Pull #1

github

web-flow
Merge 737eee7f4 into 3e01f444a
Pull Request #1: Add App and required resources

343 of 343 new or added lines in 7 files covered. (100.0%)

343 of 343 relevant lines covered (100.0%)

219.19 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/system/callback_termination.go
1
package system
2

3
import (
4
        "github.com/mlange-42/ark-tools/resource"
5
        "github.com/mlange-42/ark/ecs"
6
)
7

8
// CallbackTermination system.
9
//
10
// Terminates a run according to the return value of a callback function.
11
//
12
// Expects a resource of type [app.Termination].
13
type CallbackTermination struct {
14
        Callback func(t int64) bool // The callback. ends the simulation when it returns true.
15
        termRes  ecs.Resource[resource.Termination]
16
        step     int64
17
}
18

19
// Initialize the system
20
func (s *CallbackTermination) Initialize(w *ecs.World) {
2✔
21
        s.termRes = ecs.NewResource[resource.Termination](w)
2✔
22
        s.step = 0
2✔
23
}
2✔
24

25
// Update the system
26
func (s *CallbackTermination) Update(w *ecs.World) {
200✔
27
        term := s.termRes.Get()
200✔
28

200✔
29
        if s.Callback(s.step) {
202✔
30
                term.Terminate = true
2✔
31
        }
2✔
32
        s.step++
200✔
33
}
34

35
// Finalize the system
36
func (s *CallbackTermination) Finalize(w *ecs.World) {}
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc