(module templates-test mzscheme
(require "test-harness.ss"
(lib "etc.ss")
"utilities.ss"
"templates.ss")
(define (test-lookup-template symbol number macro? wrap? expected)
(let-values ([(t n) (lookup-template symbol number macro? wrap?)])
(test t expected)))
(define (tests)
(print-tests true)
(test-lookup-template 'let 0 true false "(let ([$name$ $binding$] ***) \n $body$ +++)")
(test-lookup-template 'bar 0 true false "(bar $expr$ ---)")
(test-lookup-template 'foo 0 true false "(foo $expr$ ---)")
(test-lookup-template 'id 0 true false "(id $expr$)")
(test-lookup-template 'let 0 false false "(let ([$name$ $binding$] ***) \n $body$ +++)")
(test-lookup-template 'bar 0 false false "bar")
(test-lookup-template 'foo 0 false false "foo")
(test-lookup-template 'id 0 false false "id")
(test (placeholder/stx? #'||) false)
(test (placeholder/stx? #'| |) false)
(test (placeholder/stx? #'|a b c |) false)
(test (placeholder/stx? #'|$$|) true)
(test (placeholder/stx? #'|$|) false)
(test (placeholder/stx? #'|$ $ $ $ $ |) false)
(test (placeholder/stx? #'|$ $ $|) true)
(test (placeholder/string? "") false)
(test (placeholder/string? " ") false)
(test (placeholder/string? "a") false)
(test (placeholder/string? "foo") false)
(test (placeholder/string? "bar") false)
(test (placeholder/string? "$$") true)
(test (placeholder/string? "$ $") true)
(test (placeholder/string? " $ $ $") false)
(test (placeholder/string? "$$$") true)
(test (placeholder/string? "$") false)
(test (holder/ellipsis? #'||) false)
(test (holder/ellipsis? #'|-|) false)
(test (holder/ellipsis? #'|--|) false)
(test (holder/ellipsis? #'|---|) true)
(test (holder/ellipsis? #'|----|) false)
(test (holder/ellipsis? #'|-----|) false)
(test (holder/ellipsis? #'| |) false)
(test (holder/ellipsis? #'| |) false)
(test (holder/ellipsis? #'|a|) false)
(test (holder/ellipsis? #'|$|) false)
(test (holder/ellipsis? #'|$$|) true)
(test (holder/ellipsis? #'| $expr$ |) false)
(test (holder/ellipsis? #'|$expr$|) true)
(test false (holder/ellipsis-tree? #'()))
(test false (holder/ellipsis-tree? #'(a)))
(test false (holder/ellipsis-tree? #'a))
(test true (holder/ellipsis-tree? #'---))
(test false (holder/ellipsis-tree? #'(a ---)))
(test true (holder/ellipsis-tree? #'($expr$ ---)))
(test false (holder/ellipsis-tree? #'((((((()))))))))
(test true (holder/ellipsis-tree? #'((((((($placeholder$)))))))))
(test true (holder/ellipsis-tree? #'[$name$ $binding$]))
)
(parameterize ([current-templates (lambda () mzscheme-templates)])
(tests)))