2017-11-27 02:41:49 +03:00
|
|
|
|%
|
2018-08-23 06:53:49 +03:00
|
|
|
:: $test: a test with a fully resolved path
|
|
|
|
::
|
|
|
|
+$ test [=path func=test-func]
|
|
|
|
:: $test-arm: a test with a name (derived from its arm name in a test core)
|
2018-01-07 09:51:52 +03:00
|
|
|
::
|
2018-08-23 06:53:49 +03:00
|
|
|
+$ test-arm [name=term func=test-func]
|
|
|
|
:: $test-func: a single test, as a gate; sample is entropy, produces failures
|
|
|
|
::
|
|
|
|
+$ test-func $-(@uvJ tang)
|
|
|
|
--
|
|
|
|
|%
|
|
|
|
:: +resolve-test-paths: add test names to file paths to form full identifiers
|
2018-01-07 09:51:52 +03:00
|
|
|
::
|
2018-08-23 06:53:49 +03:00
|
|
|
++ resolve-test-paths
|
|
|
|
|= paths-to-tests=(map path (list test-arm))
|
|
|
|
^- (list test)
|
2018-05-25 01:39:56 +03:00
|
|
|
::
|
2018-08-23 06:53:49 +03:00
|
|
|
%- zing
|
|
|
|
%+ turn ~(tap by paths-to-tests)
|
|
|
|
|= [=path test-arms=(list test-arm)]
|
|
|
|
^- (list test)
|
|
|
|
:: strip off leading 'tests' from :path
|
|
|
|
::
|
|
|
|
=. path
|
|
|
|
?> ?=(^ path)
|
|
|
|
?> ?=(%tests i.path)
|
|
|
|
t.path
|
|
|
|
:: for each test, add the test's name to :path
|
|
|
|
::
|
|
|
|
%+ turn test-arms
|
|
|
|
|= =test-arm
|
|
|
|
^- test
|
|
|
|
[(weld path /[name.test-arm]) func.test-arm]
|
|
|
|
:: +get-test-arms: convert test arms to functions and produce them
|
2018-01-07 09:51:52 +03:00
|
|
|
::
|
2018-08-23 06:53:49 +03:00
|
|
|
++ get-test-arms
|
|
|
|
|= [test-core-type=type test-core=*]
|
|
|
|
^- (list test-arm)
|
|
|
|
::
|
|
|
|
=/ arms=(list @tas) (sort (sloe test-core-type) aor)
|
|
|
|
::
|
|
|
|
%+ turn (skim arms has-test-prefix)
|
|
|
|
|= name=term
|
|
|
|
^- test-arm
|
2018-05-25 01:39:56 +03:00
|
|
|
::
|
2018-08-23 06:53:49 +03:00
|
|
|
?> (~(nest ut (~(peek ut test-core-type) %free 6)) & p:!>((init-test)))
|
|
|
|
::
|
2018-08-23 07:28:00 +03:00
|
|
|
~| [%failed-to-compile-test-arm name]
|
2018-08-23 06:53:49 +03:00
|
|
|
=/ run-arm=[=type =nock]
|
|
|
|
(~(mint ut test-core-type) p:!>(*tang) [%limb name])
|
|
|
|
::
|
|
|
|
:- name
|
|
|
|
^- test-func
|
|
|
|
::
|
|
|
|
|= eny=@uvJ
|
|
|
|
^- tang
|
|
|
|
((hard tang) .*(test-core(+6 (init-test eny)) nock.run-arm))
|
2018-08-24 01:03:55 +03:00
|
|
|
:: +has-test-prefix: does the arm define a test we should run?
|
2018-01-07 09:51:52 +03:00
|
|
|
::
|
2018-03-10 05:37:39 +03:00
|
|
|
++ has-test-prefix
|
|
|
|
|= a=term ^- ?
|
2018-08-24 01:03:55 +03:00
|
|
|
=((end 3 5 a) 'test-')
|
2018-08-23 06:53:49 +03:00
|
|
|
:: +init-test: data initialized on a per-test basis
|
2017-11-27 02:41:49 +03:00
|
|
|
::
|
2018-08-24 01:03:55 +03:00
|
|
|
++ init-test |=(eny=@uvJ ~(. tester eny))
|
2018-08-23 06:53:49 +03:00
|
|
|
:: +tester: main testing core with helper arms to be used in tests
|
2017-11-27 02:41:49 +03:00
|
|
|
::
|
2018-08-24 01:03:55 +03:00
|
|
|
:: TODO provide a lot more helper functions.
|
|
|
|
::
|
2017-11-27 02:41:49 +03:00
|
|
|
++ tester
|
2018-08-24 01:03:55 +03:00
|
|
|
|_ eny=@uvJ
|
|
|
|
:: +expect-eq: compares !>([expected actual]) and pretty-prints the result
|
2017-11-27 02:41:49 +03:00
|
|
|
::
|
|
|
|
++ expect-eq
|
2018-03-10 06:25:29 +03:00
|
|
|
|= a=vase
|
2018-04-18 00:14:43 +03:00
|
|
|
^- tang
|
|
|
|
?@ q.a [palm+[": " ~ ~ ~]^~[>%ex-expected-pair< (sell a)]]~
|
2018-03-10 06:25:29 +03:00
|
|
|
?: =(-.q.a +.q.a)
|
2018-03-10 04:46:05 +03:00
|
|
|
~
|
2018-04-18 00:14:43 +03:00
|
|
|
:~ palm+[": " ~ ~ ~]^~[leaf+"expected" (sell (slot 2 a))]
|
|
|
|
palm+[": " ~ ~ ~]^~[leaf+"actual" (sell (slot 3 a))]
|
2017-11-27 02:41:49 +03:00
|
|
|
==
|
2018-08-29 00:21:58 +03:00
|
|
|
::
|
|
|
|
++ expect-nu-eq
|
|
|
|
|= [expected=vase actual=vase]
|
|
|
|
^- tang
|
|
|
|
::
|
|
|
|
=| result=tang
|
|
|
|
::
|
|
|
|
=? result !=(q.expected q.actual)
|
|
|
|
%+ weld result
|
|
|
|
^- tang
|
|
|
|
:~ [%palm [": " ~ ~ ~] [leaf+"expected" (sell expected) ~]]
|
|
|
|
[%palm [": " ~ ~ ~] [leaf+"actual" (sell actual) ~]]
|
|
|
|
==
|
|
|
|
::
|
|
|
|
=? result !(~(nest ut p.actual) | p.expected)
|
|
|
|
%+ weld result
|
|
|
|
^- tang
|
|
|
|
:~ :+ %palm [": " ~ ~ ~]
|
|
|
|
:~ [%leaf "failed to nest"]
|
|
|
|
(~(dunk ut p.actual) %actual)
|
|
|
|
(~(dunk ut p.expected) %expected)
|
|
|
|
== ==
|
|
|
|
result
|
2018-08-24 01:03:55 +03:00
|
|
|
:: +category: prepends a name to an error result; passes successes unchanged
|
|
|
|
::
|
2018-03-10 04:55:02 +03:00
|
|
|
++ category
|
2018-04-18 00:14:43 +03:00
|
|
|
|= [a=tape b=tang] ^- tang
|
2018-03-10 04:55:02 +03:00
|
|
|
?: =(~ b) ~ :: test OK
|
2018-04-18 00:14:43 +03:00
|
|
|
:- leaf+"in: '{a}'"
|
|
|
|
(turn b |=(c=tank rose+[~ " " ~]^~[c]))
|
2017-11-27 02:41:49 +03:00
|
|
|
--
|
|
|
|
--
|