commit f228ace20f75d2bc52120bd405ccadc69cc03b6f parent e9cefe3298be30c81faab1de5a209fdbc7623ad1 Author: Ben Greenman <types@ccs.neu.edu> Date: Tue, 20 Oct 2015 00:49:23 -0400 [overload] outline tests Diffstat:
| A | tapl/tests/stlc+overloading-tests.rkt | | | 52 | ++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 52 insertions(+), 0 deletions(-)
diff --git a/tapl/tests/stlc+overloading-tests.rkt b/tapl/tests/stlc+overloading-tests.rkt @@ -0,0 +1,52 @@ +#lang s-exp "../stlc+overloading.rkt" +(require "rackunit-typechecking.rkt") + +;; ----------------------------------------------------------------------------- +;; --- syntax for ψ types + +(typecheck-fail + (signature (α) (→ α Str Str)) + #:with-msg "We only support single-argument functions") + +(typecheck-fail + (signature (α) (→ Str Str)) + #:with-msg "Variable 'α' must be free") + +(check-type + (signature (α) (→ α Str)) + : (ψ (α) (→ α Str))) + +;; ----------------------------------------------------------------------------- +;; --- basic overloading + +;; -- creating a signature does nothing, at first +;; (signature (to-string α) (→ α Str)) + +;; (typecheck-fail +;; (to-string 1) +;; #:with-msg "no instance") + +;; (typecheck-fail +;; (to-string "yolo") +;; #:with-msg "no instance") + +;; ;; -- can later add cases to an overloaded name +;; (instance (to-string Num) +;; (λ ([x : Num]) "num")) + +;; (instance (to-string Str) +;; (λ ([x : Str]) "string")) + +;; (check-type-and-result +;; (to-string 43) +;; : Str ⇒ "num") + +;; (check-type-and-result +;; (to-string (+ 2 2)) +;; : Str ⇒ "num") + +;; (check-type-and-result +;; (to-string "hi") +;; : Str ⇒ "string") + +;; ;; --