Compare commits
4 Commits
8ed87c7d53
...
b73b68897a
Author | SHA1 | Date | |
---|---|---|---|
b73b68897a | |||
19721b4e60 | |||
a9e39b682f | |||
ee4a8d28b6 |
3
Makefile
3
Makefile
@ -1,5 +1,8 @@
|
||||
doc/index.html: doc/index.md
|
||||
pandoc -t html -f gfm < $< > $@
|
||||
|
||||
check:
|
||||
sh test/run.sh
|
||||
|
||||
watch:
|
||||
find . -type f | entr -c -d sh test/run.sh
|
||||
|
@ -27,12 +27,12 @@
|
||||
))
|
||||
})]
|
||||
(let [settings (widget:get_settings)]
|
||||
(print :font (settings:get_default_font_family)
|
||||
:size (settings:get_default_font_size))
|
||||
;; (print :font (settings:get_default_font_family)
|
||||
;; :size (settings:get_default_font_size))
|
||||
(settings:set_enable_write_console_messages_to_stdout true)
|
||||
(widget:set_settings settings))
|
||||
|
||||
{:webview (trace widget)
|
||||
{:webview widget
|
||||
:name name
|
||||
:subscribe-property-changes
|
||||
(fn [self cb]
|
||||
|
@ -34,3 +34,5 @@
|
||||
(.. socketdir "/dunlin.sock")))
|
||||
|
||||
(Gtk.main)
|
||||
|
||||
;; NO-TESTING
|
||||
|
26
keymap.fnl
26
keymap.fnl
@ -1,7 +1,7 @@
|
||||
(local { : Gdk } (require :lgi))
|
||||
(local { : view } (require :fennel))
|
||||
(local lume (require :lume))
|
||||
(import-macros {: trace} :macros)
|
||||
(import-macros {: trace : describe : expect : expect=} :macros)
|
||||
|
||||
(local modifier-keyvals
|
||||
;; we need to detect and discard modifier-only key events when
|
||||
@ -44,7 +44,7 @@
|
||||
"c" (bor m Mod.CONTROL_MASK)
|
||||
"s" (bor m Mod.MOD4_MASK)))]
|
||||
{
|
||||
:keyval (Gdk.keyval_from_name symbol)
|
||||
:keyval (bor (Gdk.keyval_from_name symbol) 0)
|
||||
: modmask
|
||||
}))
|
||||
|
||||
@ -73,11 +73,13 @@
|
||||
(table.insert chars (Gdk.keyval_name keyval))
|
||||
(table.concat chars "-")))
|
||||
|
||||
(let [v (index->string "103:0")] (assert (= v "g") v))
|
||||
(let [v (index->string "65:0")] (assert (= v "A") v))
|
||||
(let [v (index->string "120:4")] (assert (= v "C-x") v))
|
||||
(let [v (index->string "100:8")] (assert (= v "M-d") v))
|
||||
(let [v (index->string "100:12")] (assert (= v "C-M-d") v))
|
||||
(describe
|
||||
index->string
|
||||
(expect= (index->string "103:0") "g")
|
||||
(expect= (index->string "65:0") "A")
|
||||
(expect= (index->string "120:4") "C-x")
|
||||
(expect= (index->string "100:8") "M-d")
|
||||
(expect= (index->string "100:12") "C-M-d"))
|
||||
|
||||
(fn command? [tbl]
|
||||
;; a keymap entry has a string as key, a command
|
||||
@ -101,10 +103,12 @@
|
||||
[k1] (. tbl k1)
|
||||
x tbl)))
|
||||
|
||||
(let [v (ref {:a 1} [:a])] (assert (= v 1) v))
|
||||
(let [v (ref {:a {:c 7}} [:a :c])] (assert (= v 7) v))
|
||||
(let [v (ref {:a {:c 7}} [:a ])] (assert (match v {:c 7} true) (view v)))
|
||||
(let [v (ref {:a {:c 7}} [:z :d])] (assert (not v) v))
|
||||
(describe
|
||||
ref
|
||||
(let [v (ref {:a 1} [:a])] (expect= v 1))
|
||||
(let [v (ref {:a {:c 7}} [:a :c])] (expect= v 7))
|
||||
(let [v (ref {:a {:c 7}} [:a ])] (expect= v {:c 7}))
|
||||
(let [v (ref {:a {:c 7}} [:z :d])] (expect (not v))))
|
||||
|
||||
|
||||
(fn recogniser [source-keymap]
|
||||
|
24
macros.fnl
24
macros.fnl
@ -1,7 +1,27 @@
|
||||
|
||||
(fn trace [x]
|
||||
`(do
|
||||
(print :trace ,(view x) (view ,x))
|
||||
,x))
|
||||
|
||||
{ : trace }
|
||||
(fn expect [assertion]
|
||||
(let [msg (.. "expectation failed: " (view assertion))]
|
||||
`(when (not ,assertion)
|
||||
(assert false ,msg))))
|
||||
|
||||
(fn expect= [actual expected]
|
||||
`(let [view# (. (require :fennel) :view)
|
||||
ve# (view# ,expected)
|
||||
va# (view# ,actual)]
|
||||
(when (not (= ve# va#))
|
||||
(assert false
|
||||
(.. "\nexpected " ve# "\ngot " va#)
|
||||
))))
|
||||
|
||||
(fn describe [thing & body]
|
||||
(when _G.RUNNING_TESTS
|
||||
`(do (print "# " ,(view thing))
|
||||
,(unpack body))))
|
||||
|
||||
{ : trace : expect : expect= : describe }
|
||||
|
||||
;; NO-TESTING
|
||||
|
@ -1,11 +1,12 @@
|
||||
with import <nixpkgs> {} ;
|
||||
let
|
||||
just = callPackage ./. {};
|
||||
in just.overrideAttrs(o: {
|
||||
package = callPackage ./. {};
|
||||
in package.overrideAttrs(o: {
|
||||
nativeBuildInputs = o.nativeBuildInputs ++ (with pkgs; [
|
||||
socat
|
||||
overmind
|
||||
entr
|
||||
]);
|
||||
buildInputs = o.buildInputs ++ (with pkgs; [
|
||||
gobject-introspection
|
||||
gtk3
|
||||
|
@ -2,3 +2,8 @@
|
||||
for i in test/*.fnl; do
|
||||
fennel --correlate $i && echo $i OK
|
||||
done
|
||||
for i in *.fnl; do
|
||||
grep -q NO-TESTING "$i" && continue
|
||||
[ "$i" = "macros.fnl" ] && continue
|
||||
fennel test/test-helper.fnl $i && echo $i OK
|
||||
done
|
||||
|
9
test/test-helper.fnl
Normal file
9
test/test-helper.fnl
Normal file
@ -0,0 +1,9 @@
|
||||
(local fennel (require :fennel))
|
||||
(local specials (require :fennel.specials))
|
||||
|
||||
(local compiler-env
|
||||
(doto (. (specials.make-compiler-env) :_G)
|
||||
(tset "RUNNING_TESTS" true)))
|
||||
|
||||
(each [_ f (ipairs arg)]
|
||||
(fennel.dofile f { :correlate true :compilerEnv compiler-env }))
|
Loading…
Reference in New Issue
Block a user