Changeset 15
- 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 68 68 \lstset{ 69 69 language={[improved]Haskell}, 70 basicstyle=\small, 70 columns=flexible, 71 basicstyle=\small, 71 72 keywordstyle=\color{blue}\bfseries, 72 73 identifierstyle=, … … 384 385 \item HUnit 385 386 \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 398 expectFail :: Either String () -> Assertion 399 expectFail _ (Left _) = return () -- blank assertion 400 expectFail 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} 408 390 \item QuickCheck 409 391 \begin{itemize} … … 418 400 419 401 \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: 423 408 randList :: Int -> RandomMonad [Int] 424 409 425 prop_randList n = check (execRandom (seed n) (randList (n/10))) 410 prop_randList n 411 = check (execRandom (seed n) (randList (n/10))) 426 412 where 427 (削除) (削除ここまで)check ns = (all (\x -> x > 0) ns) && (sum ns == n)413 (追記) (追記ここまで)check ns = (all (\x -> x > 0) ns) && (sum ns == n) 428 414 \end{lstlisting} 429 415 \end{frame}
Note:
See TracChangeset
for help on using the changeset viewer.