-
Notifications
You must be signed in to change notification settings - Fork 463
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
49 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{-# LANGUAGE BlockArguments #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module PlutusIR.Contexts.Tests where | ||
|
||
import PlutusIR | ||
import PlutusIR.Contexts | ||
|
||
import PlutusCore.Default (DefaultFun, DefaultUni) | ||
import PlutusCore.Name.Unique (Unique (..)) | ||
import Test.Tasty (TestTree, testGroup) | ||
import Test.Tasty.HUnit (testCase, (@?=)) | ||
|
||
test_extractTyArgs :: TestTree | ||
test_extractTyArgs = | ||
testGroup | ||
"Applying extractTyArgs to an" | ||
[ testCase "empty AppContext evaluates to an empty list of ty args" do | ||
extractTyArgs AppContextEnd @?= Just ([] :: [Type TyName DefaultUni ()]) | ||
, testCase "AppContext without type applications evaluates to Nothing" do | ||
extractTyArgs (TermAppContext term () AppContextEnd) @?= Nothing | ||
, testCase "AppContext with a mix of term and type applications evaluates to Nothing" do | ||
extractTyArgs (TypeAppContext ty1 () (TermAppContext term () AppContextEnd)) @?= Nothing | ||
extractTyArgs (TermAppContext term () (TypeAppContext ty1 () AppContextEnd)) @?= Nothing | ||
, testCase "AppContext with type applications only evaluates to Just (list of ty vars)" do | ||
extractTyArgs (TypeAppContext ty1 () (TypeAppContext ty2 () AppContextEnd)) | ||
@?= Just [ty1, ty2] | ||
] | ||
|
||
---------------------------------------------------------------------------------------------------- | ||
-- Test values ------------------------------------------------------------------------------------- | ||
|
||
term :: Term TyName Name DefaultUni DefaultFun () | ||
term = Var () (Name "x" (Unique 0)) | ||
|
||
ty1 :: Type TyName DefaultUni () | ||
ty1 = TyVar () (TyName (Name "t" (Unique 0))) | ||
|
||
ty2 :: Type TyName DefaultUni () | ||
ty2 = TyVar () (TyName (Name "t" (Unique 1))) |