Tcl Library Source Code

Check-in [4be7c99b0d]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:pt::parse::peg - test - Moved table of constructed test cases, plus fixed variables out of the loop. And ensured that initialization does not extend the table evermore.
Timelines: family | ancestors | descendants | both | pt-work
Files: files | file ages | folders
SHA1: 4be7c99b0dff35d30c8480cdcc90e57c31892042
User & Date: aku 2014-06-28 21:13:31
Context
2014-06-28
21:16
Fixed the generators to generate properly listified and quoted error messages check-in: 51a676d805 user: aku tags: pt-work
21:13
pt::parse::peg - test - Moved table of constructed test cases, plus fixed variables out of the loop. And ensured that initialization does not extend the table evermore. check-in: 4be7c99b0d user: aku tags: pt-work
21:11
runtime - literal arg of param_intern is const, make it so. check-in: 0edf23877c user: aku tags: pt-work
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to modules/pt/pt_pgen.test.

72
73
74
75
76
77
78



























79
80
81
82
83
84
85
}
testing {
    useLocal pt_pgen.tcl pt::pgen ;# Generator
}

set mytestdir tests/data




























# -------------------------------------------------------------------------
# While some of the C pieces are usually not required at runtime (like
# C stack when RDE is also C), we are calling on the parser generator
# here, which still may use a different implementation. So, no
# shurtcuts, and full 16x expansion (2^4).

TestAccelDo struct::set setimpl {







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
}
testing {
    useLocal pt_pgen.tcl pt::pgen ;# Generator
}

set mytestdir tests/data

# Table of test cases ...
#             Id PEG     InText Error detail    Readable char
set     chars  {}
lappend chars  0 \{      \{     [list t \{]     \{
lappend chars  1 \[      \[     [list t \[]     \[
lappend chars  2 \"      \"     [list t \"]     \"
lappend chars  3 \\033   \033   [list t \33]    <ESC>
lappend chars  4 \\n     \n     [list t \n]     <LF>
lappend chars  5 \\r     \r     [list t \r]     <CR>
lappend chars  6 \\t     \t     [list t \t]     <TAB>
# \b, \f, \v - Extend PEG grammar to recognize. Also \e = \33
lappend chars  7 \\010   \b     [list t \b]     <BS>
lappend chars  8 \\014   \f     [list t \f]     <FF>
lappend chars  9 \\013   \v     [list t \v]     <VTAB>
lappend chars 10 \\007   \a     [list t \a]     <BEL>
lappend chars 11 { }     { }    [list t { }]    <SPACE>
lappend chars 12 \\\\    \\     [list t \\]     \\
    # math symbol, circled asterix
lappend chars 13 \\u229b \u229b [list t \u229b] \u229b
# test all control characters ... (and DEL)
# more characters: above ascii = unicode BMP.

# Grammar for all test cases below, with the actual character mapped
# in (replacing @).
set gtemplate "PEG a_pe_grammar ('@') END;"
set etemplate "Parse error at position 0 (Line 0, column 0).\n... X ...\n    ^\nExpected one of\n* The character '@'\n"

# -------------------------------------------------------------------------
# While some of the C pieces are usually not required at runtime (like
# C stack when RDE is also C), we are calling on the parser generator
# here, which still may use a different implementation. So, no
# shurtcuts, and full 16x expansion (2^4).

TestAccelDo struct::set setimpl {

Changes to modules/pt/tests/pt_pgen.tests.

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
    }

    # Testing the handling of generated parsers for single
    # characters, for characters special to Tcl, C, and
    # PEGs. I.e. ensure that the various forms of quoting are done
    # correctly.

    # Grammar for all test cases below, with the actual character
    # mapped in (replacing @).
    set gtemplate "PEG a_pe_grammar ('@') END;"
    set etemplate "Parse error at position 0 (Line 0, column 0).\n... X ...\n    ^\nExpected one of\n* The character '@'\n"

    # Table of test cases ...
    #             Id PEG     InText Error detail
    lappend chars  0 \{      \{     [list t \{]     \{
    lappend chars  1 \[      \[     [list t \[]     \[
    lappend chars  2 \"      \"     [list t \"]     \"
    lappend chars  3 \\033   \033   [list t \33]    <ESC>
    lappend chars  4 \\n     \n     [list t \n]     <LF>
    lappend chars  5 \\r     \r     [list t \r]     <CR>
    lappend chars  6 \\t     \t     [list t \t]     <TAB>
    # \b, \f, \v - Extend PEG grammar to recognize. Also \e = \33
    lappend chars  7 \\010   \b     [list t \b]     <BS>
    lappend chars  8 \\014   \f     [list t \f]     <FF>
    lappend chars  9 \\013   \v     [list t \v]     <VTAB>
    lappend chars 10 \\007   \a     [list t \a]     <BEL>
    lappend chars 11 { }     { }    [list t { }]    <SPACE>
    lappend chars 12 \\\\    \\     [list t \\]     \\
    # math symbol, circled asterix
    lappend chars 13 \\u229b \u229b [list t \u229b] \u229b
    # test all control characters ... (and DEL)
    # more characters: above ascii = unicode BMP.

    foreach {n peg input message hmsg} $chars {
	set glabel "T_$hmsg"
	set grdata [string map [list @ $peg]  $gtemplate]
	set edata  [string map [list @ $hmsg] $etemplate]

	# Make parser instance. Shared across tests.
	# Amortize the time spent on dynamically making it.







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







74
75
76
77
78
79
80


























81
82
83
84
85
86
87
    }

    # Testing the handling of generated parsers for single
    # characters, for characters special to Tcl, C, and
    # PEGs. I.e. ensure that the various forms of quoting are done
    # correctly.



























    foreach {n peg input message hmsg} $chars {
	set glabel "T_$hmsg"
	set grdata [string map [list @ $peg]  $gtemplate]
	set edata  [string map [list @ $hmsg] $etemplate]

	# Make parser instance. Shared across tests.
	# Amortize the time spent on dynamically making it.
138
139
140
141
142
143
144
145
146
147
148
149
		lassign $msg tag loc mlist
		pt::util::error2readable [list $tag $loc [lsort -dict $mlist]] X
	    } -result $edata

	# Kill shared parser instance.
	$p destroy
    }

}


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







|
|
<
<

112
113
114
115
116
117
118
119
120


121
		lassign $msg tag loc mlist
		pt::util::error2readable [list $tag $loc [lsort -dict $mlist]] X
	    } -result $edata

	# Kill shared parser instance.
	$p destroy
    }
}



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