Compare commits

..

No commits in common. "b73b68897a8e05977f7e4a7b56416d34bdb99f16" and "8ed87c7d5359cb027b95da163616e1de27265325" have entirely different histories.

8 changed files with 18 additions and 62 deletions

View File

@ -1,8 +1,5 @@
doc/index.html: doc/index.md doc/index.html: doc/index.md
pandoc -t html -f gfm < $< > $@ pandoc -t html -f gfm < $< > $@
check:
sh test/run.sh
watch: watch:
find . -type f | entr -c -d sh test/run.sh find . -type f | entr -c -d sh test/run.sh

View File

@ -27,12 +27,12 @@
)) ))
})] })]
(let [settings (widget:get_settings)] (let [settings (widget:get_settings)]
;; (print :font (settings:get_default_font_family) (print :font (settings:get_default_font_family)
;; :size (settings:get_default_font_size)) :size (settings:get_default_font_size))
(settings:set_enable_write_console_messages_to_stdout true) (settings:set_enable_write_console_messages_to_stdout true)
(widget:set_settings settings)) (widget:set_settings settings))
{:webview widget {:webview (trace widget)
:name name :name name
:subscribe-property-changes :subscribe-property-changes
(fn [self cb] (fn [self cb]

View File

@ -34,5 +34,3 @@
(.. socketdir "/dunlin.sock"))) (.. socketdir "/dunlin.sock")))
(Gtk.main) (Gtk.main)
;; NO-TESTING

View File

@ -1,7 +1,7 @@
(local { : Gdk } (require :lgi)) (local { : Gdk } (require :lgi))
(local { : view } (require :fennel)) (local { : view } (require :fennel))
(local lume (require :lume)) (local lume (require :lume))
(import-macros {: trace : describe : expect : expect=} :macros) (import-macros {: trace} :macros)
(local modifier-keyvals (local modifier-keyvals
;; we need to detect and discard modifier-only key events when ;; we need to detect and discard modifier-only key events when
@ -44,7 +44,7 @@
"c" (bor m Mod.CONTROL_MASK) "c" (bor m Mod.CONTROL_MASK)
"s" (bor m Mod.MOD4_MASK)))] "s" (bor m Mod.MOD4_MASK)))]
{ {
:keyval (bor (Gdk.keyval_from_name symbol) 0) :keyval (Gdk.keyval_from_name symbol)
: modmask : modmask
})) }))
@ -73,13 +73,11 @@
(table.insert chars (Gdk.keyval_name keyval)) (table.insert chars (Gdk.keyval_name keyval))
(table.concat chars "-"))) (table.concat chars "-")))
(describe (let [v (index->string "103:0")] (assert (= v "g") v))
index->string (let [v (index->string "65:0")] (assert (= v "A") v))
(expect= (index->string "103:0") "g") (let [v (index->string "120:4")] (assert (= v "C-x") v))
(expect= (index->string "65:0") "A") (let [v (index->string "100:8")] (assert (= v "M-d") v))
(expect= (index->string "120:4") "C-x") (let [v (index->string "100:12")] (assert (= v "C-M-d") v))
(expect= (index->string "100:8") "M-d")
(expect= (index->string "100:12") "C-M-d"))
(fn command? [tbl] (fn command? [tbl]
;; a keymap entry has a string as key, a command ;; a keymap entry has a string as key, a command
@ -103,12 +101,10 @@
[k1] (. tbl k1) [k1] (. tbl k1)
x tbl))) x tbl)))
(describe (let [v (ref {:a 1} [:a])] (assert (= v 1) v))
ref (let [v (ref {:a {:c 7}} [:a :c])] (assert (= v 7) v))
(let [v (ref {:a 1} [:a])] (expect= v 1)) (let [v (ref {:a {:c 7}} [:a ])] (assert (match v {:c 7} true) (view v)))
(let [v (ref {:a {:c 7}} [:a :c])] (expect= v 7)) (let [v (ref {:a {:c 7}} [:z :d])] (assert (not v) v))
(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] (fn recogniser [source-keymap]

View File

@ -1,27 +1,7 @@
(fn trace [x] (fn trace [x]
`(do `(do
(print :trace ,(view x) (view ,x)) (print :trace ,(view x) (view ,x))
,x)) ,x))
(fn expect [assertion] { : trace }
(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

View File

@ -1,12 +1,11 @@
with import <nixpkgs> {} ; with import <nixpkgs> {} ;
let let
package = callPackage ./. {}; just = callPackage ./. {};
in package.overrideAttrs(o: { in just.overrideAttrs(o: {
nativeBuildInputs = o.nativeBuildInputs ++ (with pkgs; [ nativeBuildInputs = o.nativeBuildInputs ++ (with pkgs; [
socat socat
overmind overmind
entr entr
]);
buildInputs = o.buildInputs ++ (with pkgs; [ buildInputs = o.buildInputs ++ (with pkgs; [
gobject-introspection gobject-introspection
gtk3 gtk3

View File

@ -2,8 +2,3 @@
for i in test/*.fnl; do for i in test/*.fnl; do
fennel --correlate $i && echo $i OK fennel --correlate $i && echo $i OK
done 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

View File

@ -1,9 +0,0 @@
(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 }))