Context Navigation


Changeset 15


Ignore:
Timestamp:
Nov 22, 2007, 10:21:40 PM (18 years ago)
Author:
neil.c.c.brown
Message:

Combined some of the slides on testing frameworks, and changed the code listings to use flexible formatting rather than fixed (monospace)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • docs/trunk/200711-tock-seminars/200711-tock-slides.tex

    r14 r15
    6868\lstset{
    6969 language={[improved]Haskell},
    70 basicstyle=\small,
    70 columns=flexible,
    71 basicstyle=\small,
    7172 keywordstyle=\color{blue}\bfseries,
    7273 identifierstyle=,
    384385 \item HUnit
    385386 \begin{itemize}
    386 \item Like JUnit, simple tests with assertions
    387 \item Best approach for testing transformation passes, the
    388 parser, and the backends
    389 \end{itemize}
    390\end{itemize}
    391\end{frame}
    392
    393\begin{frame}[fragile]
    394\frametitle{HUnit example}
    395\begin{lstlisting}
    396(assertEqual "Test 0") "foo_bar" (cStyleNames "foo.bar")
    397
    398expectFail :: Either String () -> Assertion
    399expectFail _ (Left _) = return () -- blank assertion
    400expectFail testName (Right _)
    401 = assertFailure (testName ++ " expected to fail, but passed")
    402\end{lstlisting}
    403\end{frame}
    404
    405\begin{frame}
    406\frametitle{Testing frameworks}
    407\begin{itemize}
    387 \item Like JUnit; simple tests with assertions
    388 \item Best approach for most tests
    389 \end{itemize}
    408390 \item QuickCheck
    409391 \begin{itemize}
    418400
    419401\begin{frame}[fragile]
    420\frametitle{QuickCheck example}
    421\begin{lstlisting}
    422-- Generates a list of random numbers that sums to the given total
    402\frametitle{Testing Frameworks Examples}
    403\begin{lstlisting}
    404-- HUnit example:
    405(assertEqual "Test 0") "foo_bar" (cStyleNames "foo.bar")
    406
    407-- Generates a list of random numbers that sums to the given total:
    423408randList :: Int -> RandomMonad [Int]
    424409
    425prop_randList n = check (execRandom (seed n) (randList (n/10)))
    410prop_randList n
    411 = check (execRandom (seed n) (randList (n/10)))
    426412 where
    427 (削除) (削除ここまで)check ns = (all (\x -> x > 0) ns) && (sum ns == n)
    413 (追記) (追記ここまで)check ns = (all (\x -> x > 0) ns) && (sum ns == n)
    428414\end{lstlisting}
    429415\end{frame}
Note: See TracChangeset for help on using the changeset viewer.

AltStyle によって変換されたページ (->オリジナル) /