Skip to content

Commit

Permalink
Reorganize test files
Browse files Browse the repository at this point in the history
  • Loading branch information
chengluyu committed Jan 9, 2025
1 parent a19bda2 commit b757626
Show file tree
Hide file tree
Showing 5 changed files with 820 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,6 @@ enum DeBrujinSplit:
case Accept(outcome: Int)
case Reject

def firstPatterns: Set[PatternStub] =
def go(split: DeBrujinSplit, target: Int): Set[PatternStub] =
split match
case Binder(body) => go(body, target + 1)
case Branch(scrutinee, pattern, consequence, alternative) =>
go(consequence, target) ++ go(alternative, target) ++
(if scrutinee == target then Set(pattern) else Set())
case Accept(_) | Reject => Set()
go(this, Outermost)

def showDbg: Str =
def go(split: DeBrujinSplit): Str = split match
case Binder(body) =>
Expand Down
24 changes: 21 additions & 3 deletions hkmc2/shared/src/test/mlscript/rp/nondeterminism/EvenOddTree.mls
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,29 @@ class Pair[A, B](first: A, second: B)
[A, B]
//│ = [ A { class: [class A] }, B { class: [class B] } ]

:cp
pattern OddTree = A | Pair(EvenTree, OddTree) | Pair(OddTree, EvenTree)
pattern EvenTree = B | Pair(EvenTree, EvenTree) | Pair(OddTree, OddTree)

// This does not work for now.

// :cp
A is OddTree
//│ = true
:cp
:ucs desugared rp:normalize rp:expand rp:memo
A is EvenTree
//│ Desugared:
//│ > if
//│ > let $scrut = globalThis:block#1#666(.)A‹member:A›
//│ > $scrut is EvenTree then true
//│ > else false
//│ FAILURE: Unexpected exception
//│ /!!!\ Uncaught error: java.lang.Exception: Internal Error: found unelaborated pattern: EvenTree
//│ at: mlscript.utils.package$.lastWords(package.scala:230)
//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.$anonfun$10(DeBrujinSplit.scala:292)
//│ at: scala.Option.getOrElse(Option.scala:201)
//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$12$$anonfun$1(DeBrujinSplit.scala:292)
//│ at: hkmc2.utils.TraceLogger.scoped(TraceLogger.scala:37)
//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$12(DeBrujinSplit.scala:350)
//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$12$$anonfun$1(DeBrujinSplit.scala:285)
//│ at: hkmc2.utils.TraceLogger.scoped(TraceLogger.scala:37)
//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.go$12(DeBrujinSplit.scala:350)
//│ at: hkmc2.semantics.ucs.DeBrujinSplit$package$.normalize(DeBrujinSplit.scala:352)
75 changes: 0 additions & 75 deletions hkmc2/shared/src/test/mlscript/rp/nondeterminism/NullTree.mls

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ pattern Bit = 0 | 1
:cp
pattern BitTree = null | Pair(Bit | BitTree, Bit | BitTree)

:todo
:cp
null is BitTree
//│ = true

:todo
:cp
Pair(null, null) is BitTree
//│ = true
//│ = false

// :ucs rp:elaborated
pattern BinTree = null | Pair(BinTree | 0 | 1, BinTree | 0 | 1)
Expand Down
Loading

0 comments on commit b757626

Please sign in to comment.