Advertisement
Guest User

tests

a guest
Nov 20th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. module TestPrograms where
  2.  
  3. data Maybe (A : Set) : Set where
  4. just : A → Maybe A
  5. nothing : Maybe A
  6.  
  7. isJust : {A : Set} → Maybe A → Set
  8. isJust (just _) = Truth
  9. isJust nothing = Falsehood
  10.  
  11. extract : {A : Set} → (m : Maybe A) → (_ : isJust m) → A
  12. extract (just e) _ = e
  13. extract nothing ()
  14.  
  15.  
  16. -- The definition of ¬ given in the assignment is flawed;
  17. -- the tests use this instead.
  18. not : Set → Set
  19. not A = A → Falsehood
  20.  
  21. module ScopeTesting where
  22. open WellTypedPrograms
  23. open WellScopedPrograms
  24.  
  25. test₁ : let S = localInt x In
  26. x ≔ᴵ (const (pos zero))
  27. end
  28. in
  29. (extract (just S) witness) WellScoped
  30. test₁ = {!!}
  31.  
  32. test₂ : let S = localInt x In
  33. if varᴵ x < const (pos (suc (suc zero)))
  34. then localInt y In skip end
  35. else localInt z In skip end
  36. end
  37. end
  38. in
  39. (extract (just S) witness) WellScoped
  40. test₂ = {!!}
  41.  
  42. test₃ : let S = x ≔ᴵ const (pos zero)
  43. in
  44. not ((extract (just S) witness) WellScoped)
  45. test₃ = {!!}
  46.  
  47.  
  48. module InitialisationTesting where
  49. open WellTypedPrograms
  50. open WellInitialised
  51.  
  52. test₁ : (extract (just skip) witness) WellInitialised
  53. test₁ = {!!}
  54.  
  55. test₂ : let S = localInt x In
  56. x ≔ᴵ const (pos zero)
  57. end
  58. in
  59. (extract (just S) witness) WellInitialised
  60. test₂ = {!!}
  61.  
  62. -- This is well-scoped, but not well-initialised, as we use x
  63. -- before assigning to it.
  64. -- Case split on bad here until you reach ().
  65. test₃ : let S = localInt x In
  66. if varᴵ x < const (pos (suc (suc zero)))
  67. then localInt y In skip end
  68. else localInt z In skip end
  69. end
  70. end
  71. in
  72. not ((extract (just S) witness) WellInitialised)
  73. test₃ = {!!}
  74.  
  75. -- This is not well-scoped, but is well-initialised.
  76. test₄ : let S = x ≔ᴵ const (pos zero)
  77. in
  78. (extract (just S) witness) WellInitialised
  79. test₄ = {!!}
  80.  
  81. -- similar to test₄, this is well-initialised, though not well-scoped
  82. test₅ : let S = x ≔ᴵ (const (pos zero)) ⨾
  83. x ≔ᴵ (varᴵ x + const (pos (suc zero)))
  84. in
  85. (extract (just S) witness) WellInitialised
  86. test₅ = {!!}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement