test.scm 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. ; -*- mode: scheme; coding: utf-8 -*-
  2. ; Test reader extension for raw strings
  3. (import (raw-strings) (srfi srfi-26) (srfi srfi-64))
  4. (set! test-log-to-file #f)
  5. (define (test-reader s)
  6. (call-with-input-string s
  7. (cute (@@ (raw-strings) reader-extension-raw-string) #\R <>)))
  8. (define-syntax test-error-properly
  9. (syntax-rules ()
  10. ((_ tag expr)
  11. (begin
  12. (test-error tag expr)
  13. (let ((r (test-result-ref (test-runner-current) 'actual-error)))
  14. (test-equal tag (car r)))))))
  15. (test-begin "raw-strings")
  16. (test-error-properly 'raw-string-delimiter-not-found (test-reader "xxx||"))
  17. (test-error-properly 'end-of-file-reading-raw-string (test-reader "xxx(thest|\"ring)xx"))
  18. (test-equal "thest|\"ring" (test-reader "xxx(thest|\"ring)xxx"))
  19. (test-equal "thestring)xxyTHENMORE" (test-reader "xxx(thestring)xxyTHENMORE)xxx"))
  20. (test-equal "zeroprefix" (test-reader "(zeroprefix)"))
  21. (test-equal "thest|\\\"ring" #Rxxx(thest|\"ring)xxx)
  22. (test-equal "thestring)xxyTHENMORE" #Rxxx(thestring)xxyTHENMORE)xxx)
  23. (test-equal "zero(\\prefix" #R(zero(\prefix))
  24. (test-equal "hello" #R"hello")
  25. (test-equal "(hello)" #R"(hello)")
  26. (test-equal "\"hello\"" #R("hello"))
  27. (test-equal "(hello)" #R[(hello)])
  28. (test-equal #R-"he-""- "he-\"")
  29. (test-equal #R-(he-))- "he-)")
  30. (test-equal #R-(he-)))- "he-))")
  31. (test-equal #R-(he-()- "he-(")
  32. (test-equal #R***"he***"**"*** "he***\"**")
  33. (test-equal #R***"he***""*** "he***\"")
  34. #R-(This is a long string,
  35. full of bad stuff like \ ' " \" \n ) ( etc.
  36. that finally ends.)-
  37. #R-"This is a long string,
  38. full of bad stuff like \ ' " \" \n ) ( etc.
  39. that finally ends."-
  40. (define error-count (test-runner-fail-count (test-runner-current)))
  41. (test-end "raw-strings")
  42. (exit error-count)