Skip to content

Commit

Permalink
Add lab2
Browse files Browse the repository at this point in the history
  • Loading branch information
ProgMiner committed Nov 8, 2021
1 parent 5d00709 commit 975089e
Show file tree
Hide file tree
Showing 3 changed files with 567 additions and 0 deletions.
37 changes: 37 additions & 0 deletions lab2/llist-property-tests.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#lang racket

(require rackunit)
(require rackcheck)

(require "llist.rkt")


(define-property llist->list-is-inverse-of-list->llist
([xs (gen:list gen:natural)])
(check-equal? (llist->list (list->llist xs)) xs))

(define-property llist-append-associative
([as (gen:list gen:natural)]
[bs (gen:list gen:natural)]
[cs (gen:list gen:natural)])
(let ([a (list->llist as)]
[b (list->llist bs)]
[c (list->llist cs)])
(check-equal?
(llist->list (llist-append a (llist-append b c)))
(llist->list (llist-append (llist-append a b) c)))))

(define-property llist-null-is-neutral-for-append
([xs (gen:list gen:natural)])
(let ([x (list->llist xs)])
(check-equal?
(llist->list (llist-append llist-null x))
xs)

(check-equal?
(llist->list (llist-append llist-null x))
(llist->list (llist-append x llist-null)))))

(check-property llist->list-is-inverse-of-list->llist)
(check-property llist-append-associative)
(check-property llist-null-is-neutral-for-append)
Loading

0 comments on commit 975089e

Please sign in to comment.