HTML and CSS Reference
In-Depth Information
\ s
characters would fail in all browsers, possibly leading us to conclude that the
character class isn't supposed to match the specific character being tested.
4.1.2 The Sweet Spot for Learning Tests
Even though we should exercise healthy skepticism toward “programming by ob-
servation,” the learning test can be a very helpful tool aiding our understanding of
the JavaScript language and the environments in which it runs. In this section we
will run through a few cases where learning tests can help more efficiently accelerate
and maintain learning and knowledge of the language. Capturing Wisdom Found in the Wild
The learning test is the perfect tool to capture some wisdom picked up while reading
someone else's code, an article or a book. This might not be something entirely new;
it could be as simple as a clever trick. Writing it down as a test case provides several
benefits. For one, it puts us through actually writing the code down, helping us
remember whatever it is we are picking up. Second, having the code isolated in the
test allows us to more easily play with it and run it in several browsers. It also means
we can copy and modify it a few times over, bending it to learn more from it. As
always, keeping the test with the rest of the learning tests provides documentation
that can be reviewed at a later point. Exploring Weird Behavior
Every now and then we stumble upon weird bugs or other unexpected behavior
when developing production code. Failing to draw the necessary lessons from such
experiences will set us at risk for repeating the mistake. Isolating the nature of the
bug in a learning test can help us control iffy situations and become aware of them
when they arise, helping us spot them as they're forming rather than when they're
causing bugs in the code. Exploring New Browsers
Keeping a suite of learning tests can kick start exploration of a newly released
browser. Does the browser change any behaviors we have come to rely on? Does it
fix any bugs we are currently working our way around? I'm not saying we should
manually maintain comprehensive test suites for ECMA-262, the DOM, and other
interfaces, but running a suite of learning tests in a newly released browser means
we can check how our accumulated experience holds up, and it might immediately
teach us something new.
Search WWH ::

Custom Search