tools.coverage: add tests, fixes #433
parent
485932eff1
commit
0cf6541847
|
@ -0,0 +1,75 @@
|
||||||
|
! Copyright (C) 2014 Jon Harper.
|
||||||
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
USING: arrays kernel sequences sorting tools.coverage
|
||||||
|
tools.coverage.private tools.coverage.testvocab tools.coverage.testvocab.child
|
||||||
|
tools.coverage.testvocab.private tools.test vocabs.loader ;
|
||||||
|
IN: tools.coverage.tests
|
||||||
|
|
||||||
|
{ "foo.private" } [ "foo" private-vocab-name ] unit-test
|
||||||
|
{ "foo.private" } [ "foo.private" private-vocab-name ] unit-test
|
||||||
|
|
||||||
|
{
|
||||||
|
{ halftested mconcat testcond testfry testif testifprivate testmacro untested
|
||||||
|
}
|
||||||
|
} [ "tools.coverage.testvocab" [ ] map-words natural-sort ] unit-test
|
||||||
|
|
||||||
|
{ t } [
|
||||||
|
"tools.coverage.testvocab"
|
||||||
|
[ V{ } clone [ [ push ] curry each-word ] keep >array ]
|
||||||
|
[ [ ] map-words ] bi =
|
||||||
|
] unit-test
|
||||||
|
|
||||||
|
{
|
||||||
|
{ testifprivate }
|
||||||
|
} [ "tools.coverage.testvocab.private" [ ] map-words natural-sort ] unit-test
|
||||||
|
|
||||||
|
{ t } [
|
||||||
|
"tools.coverage.testvocab.private"
|
||||||
|
[ V{ } clone [ [ push ] curry each-word ] keep >array ]
|
||||||
|
[ [ ] map-words ] bi =
|
||||||
|
] unit-test
|
||||||
|
|
||||||
|
{ 3 } [ \ testif count-callables ] unit-test
|
||||||
|
|
||||||
|
! Need to reload to flush macro cache
|
||||||
|
! and have correct coverage statistics
|
||||||
|
{
|
||||||
|
{
|
||||||
|
{ halftested { [ ] } }
|
||||||
|
{ mconcat { } }
|
||||||
|
{ testcond { } }
|
||||||
|
{ testfry { } }
|
||||||
|
{ testif { } }
|
||||||
|
{ testifprivate { } }
|
||||||
|
{ testmacro { } }
|
||||||
|
{ untested { [ ] } }
|
||||||
|
}
|
||||||
|
} [ "tools.coverage.testvocab" [ reload ] [ test-coverage natural-sort ] bi ] unit-test
|
||||||
|
|
||||||
|
{ 0.75 } [ "tools.coverage.testvocab.child" [ reload ] [ %coverage ] bi ] unit-test
|
||||||
|
|
||||||
|
{
|
||||||
|
{
|
||||||
|
{
|
||||||
|
"tools.coverage.testvocab"
|
||||||
|
{
|
||||||
|
{ halftested { [ ] } }
|
||||||
|
{ mconcat { } }
|
||||||
|
{ testcond { } }
|
||||||
|
{ testfry { } }
|
||||||
|
{ testif { } }
|
||||||
|
{ testifprivate { } }
|
||||||
|
{ testmacro { } }
|
||||||
|
{ untested { [ ] } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"tools.coverage.testvocab.child"
|
||||||
|
{ { child-halftested { [ ] } } { foo { } } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} [
|
||||||
|
"tools.coverage.testvocab.child" reload
|
||||||
|
"tools.coverage.testvocab" [ reload ] [ test-coverage-recursively ] bi natural-sort
|
||||||
|
[ first2 natural-sort 2array ] map
|
||||||
|
] unit-test
|
|
@ -0,0 +1 @@
|
||||||
|
Jon Harper
|
|
@ -0,0 +1 @@
|
||||||
|
Jon Harper
|
|
@ -0,0 +1,7 @@
|
||||||
|
! Copyright (C) 2014 Jon Harper.
|
||||||
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
USING: tools.test tools.coverage.testvocab.child ;
|
||||||
|
IN: tools.coverage.testvocab.child.tests
|
||||||
|
|
||||||
|
{ } [ foo ] unit-test
|
||||||
|
{ } [ t child-halftested ] unit-test
|
|
@ -0,0 +1,7 @@
|
||||||
|
! Copyright (C) 2014 Jon Harper.
|
||||||
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
USING: kernel ;
|
||||||
|
IN: tools.coverage.testvocab.child
|
||||||
|
|
||||||
|
: foo ( -- ) ;
|
||||||
|
: child-halftested ( ? -- ) [ ] [ ] if ;
|
|
@ -0,0 +1,10 @@
|
||||||
|
! Copyright (C) 2014 Jon Harper.
|
||||||
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
USING: help.markup help.syntax kernel quotations sequences ;
|
||||||
|
IN: tools.coverage.testvocab
|
||||||
|
|
||||||
|
ARTICLE: "tools.coverage.testvocab" "tools.coverage.testvocab"
|
||||||
|
"The " { $vocab-link "tools.coverage.testdata" } " vocabulary is just a dummy vocabulary to test " { $vocab-link "tools.coverage" } "." ;
|
||||||
|
|
||||||
|
ABOUT: "tools.coverage.testvocab"
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
! Copyright (C) 2014 Jon Harper.
|
||||||
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
USING: tools.test tools.coverage.testvocab tools.coverage.testvocab.private ;
|
||||||
|
IN: tools.coverage.testvocab.tests
|
||||||
|
|
||||||
|
{ } [ t testifprivate ] unit-test
|
||||||
|
{ } [ f testifprivate ] unit-test
|
||||||
|
{ } [ t testif ] unit-test
|
||||||
|
{ } [ f testif ] unit-test
|
||||||
|
{ } [ f halftested ] unit-test
|
||||||
|
{ 0 } [ 0 testcond ] unit-test
|
||||||
|
{ 1 } [ 1 testcond ] unit-test
|
||||||
|
{ 2 } [ 2 testcond ] unit-test
|
||||||
|
{ 1 2 3 } [ { [ 1 ] [ 2 3 ] } mconcat ] unit-test
|
||||||
|
{ } [ 1 2 testmacro ] unit-test
|
||||||
|
{ } [ 2 1 testmacro ] unit-test
|
||||||
|
{ } [ t testfry ] unit-test
|
||||||
|
{ } [ f testfry ] unit-test
|
|
@ -0,0 +1,29 @@
|
||||||
|
! Copyright (C) 2014 Jon Harper.
|
||||||
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
USING: combinators fry kernel macros math sequences ;
|
||||||
|
IN: tools.coverage.testvocab
|
||||||
|
|
||||||
|
<PRIVATE
|
||||||
|
|
||||||
|
: testifprivate ( ? -- ) [ ] [ ] if ;
|
||||||
|
|
||||||
|
PRIVATE>
|
||||||
|
|
||||||
|
: halftested ( ? -- ) [ ] [ ] if ;
|
||||||
|
: testif ( ? -- ) [ ] [ ] if ;
|
||||||
|
: testcond ( n -- n ) {
|
||||||
|
{ [ dup 0 = ] [ ] }
|
||||||
|
{ [ dup 1 = ] [ ] }
|
||||||
|
[ ]
|
||||||
|
} cond ;
|
||||||
|
|
||||||
|
MACRO: mconcat ( seq -- quot ) concat ;
|
||||||
|
: testmacro ( a b -- )
|
||||||
|
{ [ 2dup ] [ <= [ ] [ ] if ] [ > [ ] [ ] if ] } mconcat ;
|
||||||
|
|
||||||
|
: testfry ( ? -- )
|
||||||
|
'[ _ [ ] [ ] if ] call ;
|
||||||
|
|
||||||
|
: untested ( -- ) ;
|
||||||
|
|
||||||
|
SYMBOL: not-a-coverage-word
|
Loading…
Reference in New Issue