aboutsummaryrefslogtreecommitdiff
path: root/tests/assets-test.scm
blob: 5fea8452a1a0d3a9992c4ec1d4843480225dfc95 (plain)
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
(import test)

(include "assets.scm")
(import (downstroke assets))

(test-begin "assets")

(test-group "make-asset-registry"
  (test-assert "returns a value"
    (make-asset-registry)))

(test-group "asset-set! and asset-ref"
  (let ((reg (make-asset-registry)))
    (test "missing key returns #f"
      #f
      (asset-ref reg 'missing))

    (asset-set! reg 'my-tilemap "data")
    (test "stored value is retrievable"
      "data"
      (asset-ref reg 'my-tilemap))

    (asset-set! reg 'my-tilemap "updated")
    (test "overwrite replaces value"
      "updated"
      (asset-ref reg 'my-tilemap))

    (asset-set! reg 'other 42)
    (test "multiple keys coexist"
      "updated"
      (asset-ref reg 'my-tilemap))
    (test "second key retrievable"
      42
      (asset-ref reg 'other))))

(test-end "assets")
(test-exit)