-
Notifications
You must be signed in to change notification settings - Fork 2
Home
TeXpp have so called TeX-test where we can check how TeXpp's text parsing response to TeX. When TeX processes the input file(for example myFile.tex) we can manage TeX to write everything what it do into log file. The same we do for TeXpp. In this case outputs should be equal. It say "every action in TeXpp is the same as in TeX". This is what we require from TeXpp parser.
Note that TeX should be already installed on this workstation!
There are many test source files in texpp. They are placed in texpp/tests/tex
directory and each of them has .tex
extension. You can see the execution of this test typing make test
command in texpp/build
directory. This tests have name with prefix test_tex_*
(For example if the input file is math.tex
the test will be named test_tex_math
). These rules apply only to the comprehensive TeXpp test.
If you want to run one of tests separately you need to use appropriate semantic:
test_tex <tex_executable> <texpp_executable> inputFile
where
-
test_tex
- executable test -
<tex_executable>
- command to cal TeX. TeX should be installed in this workstation before test call. -
<texpp_executable>
- texpp execution which write log output to console. This output redirects to.log.pp
file. -
inputFile
- input TeX file to test.
The end result of TeXpp is called "sequence of tokens". Every token object in TeXpp also contain information about initial source text(origin text). Based on this we can reconstruct the original file. Stages of this test:
- run TeXpp parser to parse input file into a sequence of tokens;
- assemble(reconstruct) the source file from these tokens;
- compare initial source file with reconstructed source file(They must be the same).
This test runs for a lot of input files. They are places on texpp/tests/tex
directory and each of them has .tex extension. You can see the execution of this tests typing make test
command in texpp/build
directory. This tests have name with prefix test_source_*
(For example if the input file is math.tex
, so the test will be named test_source_math
). These rules apply only to the comprehensive TeXpp test.
But if you want to run one of test separately you need to use appropriate semantic:
test_tex file1 file2 ...
where
-
test_tex
- executable test -
file
- input TeX file to test.
This is test of TeXpp's parser mechanism. Taking into account that the parser makes a lot of work, our test consist on several separate test. So, 4 tests run simultaneously when you run parser test.
Operates with letters and commands in the input. Here we test behaviour of the parser based on peekToken()
, lastToken()
and nextToken()
methods. See description of methods in parser.h
file.
TeXpp read symbols and control sequences from input TeX-file and gives them sense. For this purpose during parser's initializing we set certain rules of their interpretation. And this rules can be changed whenever it needed. Assigning should be acting within actual scope if this assigning is local or be acting permanently if this assigning is global.
Here we can see an example of simple node tree representing. This test never fails.
Here we have test for macro command expansion.
This test for TeXpp's lexer. Lexer extract symbols from source file and produce appropriate tokens for them. So, for this purpose we have to determine several characteristics:
- Type, one of the following:
*
CHARACTER
- characters which shown as is (letters, punctuation or digits, etc.) *CONTROL
- control sequences *SKIPPED
- symbols which do not affect on outcome - Category code (is it an escape character, Begin group character, space, active character, etc.)
- Source text
- Position in source text
- Value(meaning) of token
We have a lot of separate small tests. Where everyone is unique and designed for some separate feature of lexer.
List of tests:
- lexer_empty. Task: Empty source file should not produce any of tokens.
-
lexer_physical_eol. Newline, also known as a line ending, end of line (EOL), or line break, is a special character or sequence of characters signifying the end of a line of text. The actual codes representing a newline vary across operating systems, which can be a problem. So, in this test we make unification EOL character from
\n
(Unix OS) and\r\n
(Windows OS) to certainm_endlinechar
(which is\r
by default). Nevertheless single EOL characters in TeXpp act as word separators. Only two consecutive EOL-characters (\r\r
) translate to newLine command\\par
. So, after we will setm_endlinechar
to letter(for example 'A') behavior of lexer should change appropriately. Ifm_endlinechar
is out of0...255
value it should not be inm_lineTex
at all.m_lineTex
is one line of source text with unified EOL-character. -
lexer_eol. Every separate character(and command) in TeXpp are divided into categories. So, every token contain category code value(catCode) appropriate to the token's meaning. Of course we can change this "lockup table" as we wish. In this test we change category code for EOL symbol (
\r
) fromCC_EOL
toCC_OTHER
and check lexer functionality after changing. The main purpose of this test: to check do change of category code for symbols give us predictable consequences. -
lexer_special_chars. More than 2 hundreds of symbols can be used in TeX, but not every keyboard have enough buttons. For this purpose we can type characters using character Super
^
. For example to write character with code 10 we type^^0a
. Template is^^XX
where XX is hexadecimal number. -
lexer_control. Usually backslash character() with one not letter character or sequence of letters considered as a control command. For example
\\abc
,\\%
,\\{
,\\bs
. This test check do they parsing correctly. -
lexer_comment. Here we test comment's syntax in TeXpp. Comments begin from symbol
%
and finish with end of line character. Lexer should produce oneSKIPPED
token for one comments. -
lexer_other. Check reaction on Null char symbol
\x00
from the input file.
to be continued...