|
| 1 | +import unittest, necsus |
| 2 | + |
| 3 | +proc create( |
| 4 | + sharedTuple: Shared[(float, bool)], |
| 5 | + sharedNamedTuple: Shared[tuple[num: float, truth: bool]], |
| 6 | + sharedSeq: Shared[seq[string]], |
| 7 | + sharedArray: Shared[array[5, char]], |
| 8 | +) = |
| 9 | + sharedTuple.set((3.14, true)) |
| 10 | + sharedNamedTuple.set((2.78, false)) |
| 11 | + sharedSeq.set(@[ "a", "b", "c" ]) |
| 12 | + sharedArray.set([ 'a', 'b', 'c', 'd', 'e' ]) |
| 13 | + |
| 14 | +proc assertions( |
| 15 | + sharedTuple: Shared[(float, bool)], |
| 16 | + sharedNamedTuple: Shared[tuple[num: float, truth: bool]], |
| 17 | + sharedSeq: Shared[seq[string]], |
| 18 | + sharedArray: Shared[array[5, char]], |
| 19 | +) = |
| 20 | + check(sharedTuple.get == (3.14, true)) |
| 21 | + check(sharedNamedTuple.get == (2.78, false)) |
| 22 | + check(sharedSeq.get == @[ "a", "b", "c" ]) |
| 23 | + check(sharedArray.get == [ 'a', 'b', 'c', 'd', 'e' ]) |
| 24 | + |
| 25 | +proc run(tick: proc(): void) = |
| 26 | + tick() |
| 27 | + |
| 28 | +proc testSharedVar() {.necsus(run, [~create, ~assertions], newNecsusConf()).} |
| 29 | + |
| 30 | +test "Creating shared vars with various types": |
| 31 | + testSharedVar() |
0 commit comments