start converting mlish tests to typed-lang-builder/mlish-core

This commit is contained in:
AlexKnauth 2016-06-22 12:06:43 -04:00
parent 9ea6c6b513
commit fba974d8bb
7 changed files with 10 additions and 9 deletions

View File

@ -1,4 +1,4 @@
#lang s-exp "../../mlish.rkt"
#lang s-exp "../../typed-lang-builder/mlish-core.rkt"
(require "../rackunit-typechecking.rkt")
;; pattern matching for built-in lists

View File

@ -1,4 +1,4 @@
#lang s-exp "../../mlish.rkt"
#lang s-exp "../../typed-lang-builder/mlish-core.rkt"
(require "../rackunit-typechecking.rkt")
;; datatype with no self-reference

View File

@ -1,4 +1,4 @@
#lang s-exp "../../mlish.rkt"
#lang s-exp "../../typed-lang-builder/mlish-core.rkt"
(require "../rackunit-typechecking.rkt")
;; alternate match that supports nested patterns
@ -17,14 +17,14 @@
(match2 (B (tup 2 3)) with
[A x -> x]
[C (x,y) -> y]
[B x -> x]) #:with-msg "branches have incompatible types: \\(× Int Int\\) and Int")
[B x -> x]) #:with-msg "branches have incompatible types: Int and \\(× Int Int\\)")
(typecheck-fail
(match2 (B (tup 2 3)) with
[A x -> (tup x x)]
[C x -> x]
[B x -> x])
#:with-msg "branches have incompatible types: \\(× Int \\(× Int Int\\)\\) and \\(× Int Int\\)")
#:with-msg "branches have incompatible types: \\(× Int Int\\) and \\(× Int \\(× Int Int\\)\\)")
(check-type
(match2 (B (tup 2 3)) with
@ -241,7 +241,7 @@
(match2 (list (list #t #f)) with
[nil -> -1]
[(list x y) :: tl -> (+ x y)])
#:with-msg "Type error applying function \\+")
#:with-msg "expected: Int\n *given: Bool")
;; comma tup pattern syntax

View File

@ -1,4 +1,4 @@
#lang s-exp "../../mlish.rkt"
#lang s-exp "../../typed-lang-builder/mlish-core.rkt"
(require "../rackunit-typechecking.rkt")
;; tests of polymorphic recursion

View File

@ -1,4 +1,4 @@
#lang s-exp "../../mlish.rkt"
#lang s-exp "../../typed-lang-builder/mlish-core.rkt"
(require "../rackunit-typechecking.rkt")
;; function polymorphic in list element

View File

@ -1,4 +1,4 @@
#lang s-exp "../../mlish.rkt"
#lang s-exp "../../typed-lang-builder/mlish-core.rkt"
(require "../rackunit-typechecking.rkt")
(define-type (Option X)

View File

@ -756,6 +756,7 @@
[(match e with . clauses)
[#:fail-unless (not (null? (syntax->list #'clauses))) "no clauses"]
[ [[e e-] : τ_e]]
[#:when (and (not (×? #'τ_e)) (not (List? #'τ_e)))]
[#:with t_expect (get-expected-type stx)] ; propagate inferred type
[#:with ([Clause:id x:id ...
(~optional (~seq #:when e_guard) #:defaults ([e_guard #'(ext-stlc:#%datum . #t)]))