Issue4999.agda 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. open import Agda.Builtin.Bool
  2. open import Agda.Builtin.Nat
  3. open import Agda.Builtin.Char renaming (primCharEquality to _==ᶜ_)
  4. open import Agda.Builtin.List
  5. open import Agda.Builtin.Equality
  6. open import Agda.Builtin.String renaming (primStringAppend to _++_)
  7. open import Agda.Builtin.IO
  8. open import Agda.Builtin.Unit
  9. variable
  10. A B C : Set
  11. map : (A → B) → List A → List B
  12. map f [] = []
  13. map f (x ∷ xs) = f x ∷ map f xs
  14. <?> = '\xFFFD'
  15. fromCount : Nat → Nat → List Nat
  16. fromCount 0 _ = []
  17. fromCount (suc n) a = a ∷ fromCount n (suc a)
  18. fromTo : Nat → Nat → List Nat
  19. fromTo a b = fromCount (suc b - a) a
  20. isReplaced : Nat → Bool
  21. isReplaced n = primNatToChar n ==ᶜ <?>
  22. and : List Bool → Bool
  23. and [] = true
  24. and (false ∷ _) = false
  25. and (true ∷ xs) = and xs
  26. all : (A → Bool) → List A → Bool
  27. all p xs = and (map p xs)
  28. not : Bool → Bool
  29. not false = true
  30. not true = false
  31. _∘_ : (B → C) → (A → B) → A → C
  32. f ∘ g = λ x → f (g x)
  33. postulate
  34. putStrLn : String → IO ⊤
  35. _>>_ : IO A → IO B → IO B
  36. {-# FOREIGN GHC import qualified Data.Text.IO as Text #-}
  37. {-# COMPILE GHC putStrLn = Text.putStrLn #-}
  38. {-# COMPILE GHC _>>_ = \ _ _ -> (>>) #-}
  39. assert : String → Bool → IO ⊤
  40. assert s true = putStrLn (s ++ " PASSED")
  41. assert s false = putStrLn (s ++ " FAILED")
  42. main : IO ⊤
  43. main = do
  44. assert "before surrogates" (all (not ∘ isReplaced) (fromTo 0xD780 0xD7FF))
  45. assert "surrogate range " (all isReplaced (fromTo 0xD800 0xDFFF))
  46. assert "after surrogates " (all (not ∘ isReplaced) (fromTo 0xE000 0xE07F))