Skip to content

Commit

Permalink
compiler: add test files for #61
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
Zilin Chen authored and Zilin Chen committed Mar 6, 2018
1 parent 1e3f85e commit cb22a04
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
17 changes: 17 additions & 0 deletions cogent/tests/fail_put-linear-more-than-once.cogent
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--
-- Copyright 2017, NICTA
--
-- This software may be distributed and modified according to the terms of
-- the GNU General Public License version 2. Note that NO WARRANTY is provided.
-- See "LICENSE_GPLv2.txt" for details.
--
-- @TAG(NICTA_GPL)
--

type A
type B = {f1 : U8, f2 : U8, f3 : A}

quxx : (B take f3, A, A) -> B
quxx (b,x,y) = let b' = b {f3=x}
and b'' = b' {f3=y}
in b''
18 changes: 18 additions & 0 deletions cogent/tests/fail_take-linear-more-than-once.cogent
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--
-- Copyright 2017, NICTA
--
-- This software may be distributed and modified according to the terms of
-- the GNU General Public License version 2. Note that NO WARRANTY is provided.
-- See "LICENSE_GPLv2.txt" for details.
--
-- @TAG(NICTA_GPL)
--

type A
type B = {f1 : U8, f2 : U8, f3 : A}

foo : B -> (B take f3, A, A)
foo b = let b' {f3=x} = b
and b'' {f3=y} = b'
in (b'',x,y)

4 changes: 3 additions & 1 deletion cogent/tests/fail_take-nonlinear-more-than-once.cogent
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
-- @TAG(NICTA_GPL)
--

type B = {f1 : U8, f2 : U8, f3 : Bool}
type A
type B = {f1 : U8, f2 : U8, f3 : A}

-- cannot take several times, which makes sense
baz : B -> B take (f1)
baz b = let b' {f1} = b
and b'' {f1} = b'
in b''

19 changes: 19 additions & 0 deletions cogent/tests/pass_put-nonlinear-more-than-once.cogent
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--
-- Copyright 2017, NICTA
--
-- This software may be distributed and modified according to the terms of
-- the GNU General Public License version 2. Note that NO WARRANTY is provided.
-- See "LICENSE_GPLv2.txt" for details.
--
-- @TAG(NICTA_GPL)
--

type A
type B = {f1 : U8, f2 : U8, f3 : A}

-- can put multiple times
bar : B take (f1) -> B
bar b = let b' = b {f1 = 1}
and b'' = b' {f1 = 2}
in b''

0 comments on commit cb22a04

Please sign in to comment.