aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/world
diff options
context:
space:
mode:
authorEduardo Julian2021-06-29 00:54:13 -0400
committerEduardo Julian2021-06-29 00:54:13 -0400
commit6633cd42f2892ea71530ddeeb93a7e7c0b59faa3 (patch)
treeaef31dba019fe7bc5141084ab8c25369bd7e83ca /stdlib/source/test/lux/world
parentdb3e864ae66da7f7d1034ae95967605144d5ec47 (diff)
Some updates for the new compilers.
Diffstat (limited to '')
-rw-r--r--stdlib/source/test/lux/world/input/keyboard.lux232
1 files changed, 128 insertions, 104 deletions
diff --git a/stdlib/source/test/lux/world/input/keyboard.lux b/stdlib/source/test/lux/world/input/keyboard.lux
index e38ce6271..1dde1aaa7 100644
--- a/stdlib/source/test/lux/world/input/keyboard.lux
+++ b/stdlib/source/test/lux/world/input/keyboard.lux
@@ -9,6 +9,8 @@
[collection
["." list]
["." set (#+ Set)]]]
+ [macro
+ ["." template]]
[math
["." random (#+ Random)]
[number
@@ -16,101 +18,122 @@
{1
["." /]})
-(with_expansions [<keys> (as_is /.back_space
- /.enter
- /.shift
- /.control
- /.alt
- /.caps_lock
- /.escape
- /.space
- /.page_up
- /.page_down
- /.end
- /.home
+(with_expansions [<groups> (as_is [keys/commands
+ [/.back_space
+ /.enter
+ /.shift
+ /.control
+ /.alt
+ /.caps_lock
+ /.escape
+ /.space
+ /.page_up
+ /.page_down
+ /.end
+ /.home
+ /.delete
+ /.num_lock
+ /.scroll_lock
+ /.print_screen
+ /.insert
+ /.windows
- /.left
- /.up
- /.right
- /.down
-
- /.a
- /.b
- /.c
- /.d
- /.e
- /.f
- /.g
- /.h
- /.i
- /.j
- /.k
- /.l
- /.m
- /.n
- /.o
- /.p
- /.q
- /.r
- /.s
- /.t
- /.u
- /.v
- /.w
- /.x
- /.y
- /.z
-
- /.num_pad_0
- /.num_pad_1
- /.num_pad_2
- /.num_pad_3
- /.num_pad_4
- /.num_pad_5
- /.num_pad_6
- /.num_pad_7
- /.num_pad_8
- /.num_pad_9
+ /.left
+ /.up
+ /.right
+ /.down]]
+
+ [keys/letters
+ [/.a
+ /.b
+ /.c
+ /.d
+ /.e
+ /.f
+ /.g
+ /.h
+ /.i
+ /.j
+ /.k
+ /.l
+ /.m
+ /.n
+ /.o
+ /.p
+ /.q
+ /.r
+ /.s
+ /.t
+ /.u
+ /.v
+ /.w
+ /.x
+ /.y
+ /.z]]
+
+ [keys/num_pad
+ [/.num_pad_0
+ /.num_pad_1
+ /.num_pad_2
+ /.num_pad_3
+ /.num_pad_4
+ /.num_pad_5
+ /.num_pad_6
+ /.num_pad_7
+ /.num_pad_8
+ /.num_pad_9]]
- /.delete
- /.num_lock
- /.scroll_lock
- /.print_screen
- /.insert
- /.windows
-
- /.f1
- /.f2
- /.f3
- /.f4
- /.f5
- /.f6
- /.f7
- /.f8
- /.f9
- /.f10
- /.f11
- /.f12
- /.f13
- /.f14
- /.f15
- /.f16
- /.f17
- /.f18
- /.f19
- /.f20
- /.f21
- /.f22
- /.f23
- /.f24)]
+ [keys/functions
+ [/.f1
+ /.f2
+ /.f3
+ /.f4
+ /.f5
+ /.f6
+ /.f7
+ /.f8
+ /.f9
+ /.f10
+ /.f11
+ /.f12
+ /.f13
+ /.f14
+ /.f15
+ /.f16
+ /.f17
+ /.f18
+ /.f19
+ /.f20
+ /.f21
+ /.f22
+ /.f23
+ /.f24]])]
(def: listing
(List /.Key)
- (list <keys>))
+ (list.concat (`` (list (~~ (template [<definition> <keys>]
+ [((: (-> Any (List /.Key))
+ (function (_ _)
+ (`` (list (~~ (template.splice <keys>))))))
+ [])]
+
+ <groups>))))))
(def: catalogue
(Set /.Key)
(set.from_list n.hash ..listing))
+ (def: verdict
+ (n.= (list.size ..listing)
+ (set.size ..catalogue)))
+
+ (template [<definition> <keys>]
+ [(def: <definition>
+ Test
+ (_.cover <keys>
+ ..verdict))]
+
+ <groups>)
+
(def: #export random
(Random /.Key)
(let [count (list.size ..listing)]
@@ -122,23 +145,24 @@
Test
(<| (_.covering /._)
(_.for [/.Key])
- ($_ _.and
- (_.cover [<keys>]
- (n.= (list.size ..listing)
- (set.size ..catalogue)))
+ (`` ($_ _.and
+ (~~ (template [<definition> <keys>]
+ [<definition>]
+
+ <groups>))
- (_.for [/.Press]
- (`` ($_ _.and
- (~~ (template [<pressed?> <function>]
- [(do random.monad
- [key ..random
- #let [sample (<function> key)]]
- (_.cover [<function>]
- (and (bit\= <pressed?> (get@ #/.pressed? sample))
- (n.= key (get@ #/.input sample)))))]
+ (_.for [/.Press]
+ (`` ($_ _.and
+ (~~ (template [<pressed?> <function>]
+ [(do random.monad
+ [key ..random
+ #let [sample (<function> key)]]
+ (_.cover [<function>]
+ (and (bit\= <pressed?> (get@ #/.pressed? sample))
+ (n.= key (get@ #/.input sample)))))]
- [#0 /.release]
- [#1 /.press]
- ))
- )))
- ))))
+ [#0 /.release]
+ [#1 /.press]
+ ))
+ )))
+ )))))