File: pt_peg_export_plugins.tests

package info (click to toggle)
tcllib 1.16-dfsg-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 50,040 kB
  • ctags: 18,603
  • sloc: tcl: 156,708; ansic: 14,098; sh: 10,783; xml: 1,766; yacc: 1,114; pascal: 551; makefile: 89; perl: 84; f90: 84; python: 33; ruby: 13; php: 11
file content (145 lines) | stat: -rw-r--r-- 4,741 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# -*- tcl -*-
# peg_export.testsuite: Tests for the management of grammar export plugins.
#
# Copyright (c) 2009 Andreas Kupries <andreas_kupries@users.sourceforge.net>
# All rights reserved.
#
# RCS: @(#) $Id: pt_peg_export_plugins.tests,v 1.1 2010/03/26 05:07:24 andreas_kupries Exp $

# -------------------------------------------------------------------------

# Tests are run for all formats we have an export plugin for.

# -------------------------------------------------------------------------

set mytestdir      tests/data
set mytestconfig   {fox dog lazy jump}
set mytestincludes [TestFilesGlob $mytestdir]

# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
# PEG markup (standard text representation).
# TODO :: templating

foreach {k fused section} {
    0 0 {}
    1 1 -fused
} {
    TestFilesProcess $mytestdir ok peg_serial-canonical peg_peg$section -> n label input data expected {
	test pt-peg-export-plugin-peg-set:${setimpl}-21.$k.$n "pt::peg::export /peg, $label$section, ok :- $input" -setup {
	    pt::peg::export OUT
	    OUT configuration set -fused $fused
	} -body {
	    OUT export serial $data peg
	} -cleanup {
	    OUT destroy
	} -result $expected
    }
}

# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
# json markup

foreach {k in al section} {
    0 0 0 -ultracompact
    1 1 0 -indented
    2 0 1 -indalign
    3 1 1 -indalign
} {
    TestFilesProcess $mytestdir ok peg_serial-canonical peg_json$section -> n label input data expected {
	test pt-peg-export-plugin-json-set:${setimpl}-22.$k.$n "pt::peg::export /json, $label$section, ok :- $input" -setup {
	    pt::peg::export OUT
	    OUT configuration set -indented $in
	    OUT configuration set -aligned  $al
	} -body {
	    OUT export serial $data json
	} -cleanup {
	    OUT destroy
	} -result $expected
    }
}

# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
# container markup
# TODO :: templating

foreach {k mode section} {
    0 incremental -incremental
    1 bulk        -bulk
} {
    TestFilesProcess $mytestdir ok peg_serial-canonical peg_container$section -> n label input data expected {
	test pt-peg-export-plugin-container-set:${setimpl}-23.$k.$n "pt::peg::export /container, $label$section, ok :- $input" -setup {
	    pt::peg::export OUT
	    OUT configuration set -mode $mode
	} -body {
	    OUT export serial $data container
	} -cleanup {
	    OUT destroy
	} -result $expected
    }
}

if 0 {
# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
# html markup

foreach {k nl in section} {
    0 0 0 -ultracompact
    1 0 1 -indented
    2 1 0 -compact
    3 1 1 -indented
} {
    TestFilesProcess $mytestdir ok serial html$section -> n label input data expected {
	test pt-peg-export-plugin-html-set:${setimpl}-24.$k.$n "pt::peg::export /html, $label$section, ok :- $input" -setup {
	    pt::peg::export OUT
	    OUT configuration set -newlines $nl
	    OUT configuration set -indented $in
	    OUT configuration set -user _dummy_
	} -body {
	    striphtmlcomments [OUT export serial $data html] 3
	} -cleanup {
	    OUT destroy
	} -result $expected
    }
}

# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
# wiki markup

TestFilesProcess $mytestdir ok serial wiki -> n label input data expected {
    test pt-peg-export-plugin-wiki-set:${setimpl}-25.$n "pt::peg::export /wiki, $label, ok :- $input" -setup {
	pt::peg::export OUT
    } -body {
	OUT export serial $data wiki
    } -cleanup {
	OUT destroy
    } -result $expected
}

# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
# nroff markup

foreach {k inline section} {
    0 0 -external
    1 1 -inlined
} {
    TestFilesProcess $mytestdir ok serial nroff$section -> n label input data expected {
	test pt-peg-export-plugin-nroff-set:${setimpl}-25.$k.$n "pt::peg::export /nroff, $label$section, ok :- $input" -setup {
	    pt::peg::export OUT
	    OUT configuration set -inline $inline
	} -body {
	    stripnroffcomments [stripmanmacros [OUT export serial $data nroff]]
	} -cleanup {
	    OUT destroy
	} -result $expected
    }
}}

# -------------------------------------------------------------------------
unset mytestdir n label input data expected
return