On Sun, Oct 30, 2011 at 1:47 PM, Edward K. Ream <[email protected]> wrote:
> Syntax coloring
> ============
> I plan to write "covering" tests that verify the following [snip]
My original idea was easier to understand. I probably should have
talked about that first.
The trace in the colorizer's colorRangeWithTag method is a superb
high-level view of what the colorizer is doing. For example, if the
source is::
@language python
@ doc part
@c
def spam():
'''docstring'''
s = "123"
return
the trace will be::
colorRangeWithTag python.leokeyword '@language python'
mainLoop,match_at_language
colorRangeWithTag python.leokeyword '@' mainLoop,match_doc_part
colorRangeWithTag python.docpart ' doc part' mainLoop,match_doc_part
colorRangeWithTag python.leokeyword '@c' restart,restartDocPart
colorRangeWithTag python.keyword1 'def' python_rule21,match_keywords
colorRangeWithTag python.literal2 "'''docstring'''" python_rule2,match_span
colorRangeWithTag python.operator '= python_rule5,match_seq
colorRangeWithTag python.literal1 '"123"' python_rule3,match_span
colorRangeWithTag python.keyword1 'return' python_rule21,match_keywords
Simply verifying that the source code results in these calls would be
a high-level test for the colorizer module for the Python language.
My initial description of the test was a not-very-clear generalization
of this idea.
**Important**: such a test would *not* be a unit test of
colorRangeWithTag. Rather, it would be a unit test of everything that
leads up to the calls to colorRangeWithTag.
Similarly, the trace in setTag provides more high-level information
about the actual colors used for various colorizer tags.
setTag #00aa00 leokeyword @language python
setTag #00aa00 leokeyword @
setTag firebrick docpart doc part
setTag #00aa00 leokeyword @c
setTag blue keyword1 def
setTag #00aa00 literal2 '''docstring'''
setTag #00aa00 literal1 "123"
setTag blue keyword1 return
We could generalize this into a test that all needed tags have been defined.
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/leo-editor?hl=en.