From 63bb9f5b5bcac6f8f245f0f697998efa3d0e88cc Mon Sep 17 00:00:00 2001 From: Eric Dobson Date: Wed, 12 Mar 2014 20:04:22 -0700 Subject: [PATCH] Initial version of filter tests. original commit: f7536ebfbd38e873039a98df000c347e5b10931c --- .../typed-racket/unit-tests/all-tests.rkt | 1 + .../typed-racket/unit-tests/filter-tests.rkt | 67 +++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/filter-tests.rkt diff --git a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/all-tests.rkt b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/all-tests.rkt index 8eb18ff1..086457c9 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/all-tests.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/all-tests.rkt @@ -38,4 +38,5 @@ "class-tests.rkt" "class-util-tests.rkt" "check-below-tests.rkt" + "filter-tests.rkt" "rep-tests.rkt") diff --git a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/filter-tests.rkt b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/filter-tests.rkt new file mode 100644 index 00000000..c2bc0f47 --- /dev/null +++ b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/filter-tests.rkt @@ -0,0 +1,67 @@ +#lang racket/base + +(require "test-utils.rkt" + rackunit + (types abbrev union filter-ops)) + +(provide tests) +(gen-test-main) + +(define (not-opposite? x y) (not (opposite? x y))) +(define (not-implied-atomic? x y) (not (implied-atomic? x y))) + +(define tests + (test-suite "Filters" + (test-suite "Opposite" + (check opposite? + (-filter -Symbol 0) + (-not-filter (Un -Symbol -String) 0)) + + (check opposite? + (-not-filter -Symbol 0) + (-filter -Symbol 0)) + + (check not-opposite? + (-filter -Symbol 1) + (-not-filter -Symbol 0)) + + (check not-opposite? + (-filter -String 0) + (-not-filter -Symbol 0)) + + (check not-opposite? + (-not-filter -Symbol 0) + (-filter -String 0)) + ) + + (test-suite "Implied Atomic" + (check implied-atomic? + -top -top) + (check implied-atomic? + -bot -bot) + (check not-implied-atomic? + -bot -top) + (check implied-atomic? + (-filter (Un -String -Symbol) 0) + (-filter -Symbol 0)) + (check not-implied-atomic? + (-filter -Symbol 0) + (-filter (Un -String -Symbol) 0)) + (check implied-atomic? + (-not-filter -Symbol 0) + (-not-filter (Un -String -Symbol) 0)) + (check not-implied-atomic? + (-not-filter (Un -String -Symbol) 0) + (-not-filter -Symbol 0)) + (check not-implied-atomic? + (-filter -Symbol 1) + (-filter -Symbol 0)) + (check implied-atomic? + (-filter -Symbol #'x) + (-filter -Symbol #'x)) + (check implied-atomic? + (-or (-filter -Symbol 1) (-filter -Symbol #'x)) + (-filter -Symbol #'x)) + ) + + ))