Skip to content

Commit 1791dce

Browse files
committed
move entrypoints into test dir
1 parent dda562c commit 1791dce

File tree

9 files changed

+72
-60
lines changed

9 files changed

+72
-60
lines changed

build.gradle.kts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,14 @@ tasks {
8181
}
8282
}
8383

84-
listOf("HelloKaliningraph", "Rewriter",
85-
"PrefAttach", "rewriting.CipherSolver").forEach { fileName ->
84+
listOf("HelloKaliningraph", "Rewriter", "PrefAttach",
85+
"rewriting.CipherSolver", "RegexDemo").forEach { fileName ->
8686
register(fileName, JavaExec::class) {
8787
main = "edu.mcgill.kaliningraph.${fileName}Kt"
8888
classpath = sourceSets["test"].runtimeClasspath
8989
}
9090
}
9191

92-
listOf("RegexDemo").forEach { fileName ->
93-
register(fileName, JavaExec::class) {
94-
main = "edu.mcgill.kaliningraph.automata.${fileName}Kt"
95-
classpath = sourceSets["main"].runtimeClasspath
96-
}
97-
}
98-
9992
test {
10093
useJUnitPlatform()
10194
testLogging { events("passed", "skipped", "failed") }

src/main/kotlin/edu/mcgill/kaliningraph/CyclicalReference.kt

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/main/kotlin/edu/mcgill/kaliningraph/circuits/ComputationGraph.kt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,4 @@ open class UnlabeledEdge(override val source: Gate, override val target: Gate):
124124
CGF, Edge<ComputationGraph, UnlabeledEdge, Gate>(source, target) {
125125
override fun render() = (target.render() - source.render()).add(Label.of(""))
126126
.add(if (source.neighbors.size == 1) BLACK else if (source.outgoing.indexOf(this) % 2 == 0) BLUE else RED)
127-
}
128-
129-
fun main() {
130-
CircuitBuilder {
131-
val funA by def(a, b, c) { a + b + c }
132-
j = funA(3, 2, 1)
133-
j = b * c
134-
d = e * f
135-
g = 1 - h
136-
i = a + d + g
137-
}
138-
//.reversed() //TODO: What is this even supposed to mean?
139-
// Maybe this whole tower of abstractions wasn't such a good idea after all
140-
.show()
141127
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package edu.mcgill.kaliningraph.experimental
2+
3+
// Immutable circular reference
4+
class Owl(lay: Owl.() -> Egg) { val egg by lazy { lay() } }
5+
class Egg(hatch: () -> Owl) { val owl by lazy { hatch() } }

src/main/kotlin/edu/mcgill/kaliningraph/DoublyLinkedList.kt renamed to src/main/kotlin/edu/mcgill/kaliningraph/experimental/DoublyLinkedList.kt

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,4 @@
1-
package edu.mcgill.kaliningraph
2-
3-
4-
fun main() {
5-
var head = DLL("a").let { ('c'..'f').fold(it) { a, b -> a + b.toString() } }
6-
// println(head)
7-
assertDLL(head)
8-
9-
head = head.insert("b")
10-
println(head + head)
11-
assertDLL(head)
12-
println(head.reversed())
13-
}
14-
15-
private fun assertDLL(head: DLL<String>) =
16-
(1 until head.size - 1).map { head[it] }.forEach {
17-
val isDLLForward = it.next.prev === it
18-
val isDLLBack = it.prev.next === it
19-
println(head)
20-
assert(isDLLForward) { "${it.next.prev} != $it" }
21-
assert(isDLLBack) { "${it.prev.next} != $it" }
22-
}
1+
package edu.mcgill.kaliningraph.experimental
232

243
class LL<T>(val head: T, val next: LL<T>? = null) {
254
operator fun plus(t: T): LL<T> =

src/main/kotlin/edu/mcgill/kaliningraph/HelloKaliningraph.kt renamed to src/test/kotlin/edu/mcgill/kaliningraph/HelloKaliningraph.kt

File renamed without changes.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package edu.mcgill.kaliningraph.circuits
2+
3+
import org.junit.jupiter.api.Test
4+
5+
class CGraphTest {
6+
@Test
7+
fun testCircuitBuilder() {
8+
CircuitBuilder {
9+
val funA by def(a, b, c) { a + b + c }
10+
j = funA(3, 2, 1)
11+
j = b * c
12+
d = e * f
13+
g = 1 - h
14+
i = a + d + g
15+
}
16+
//.reversed() //TODO: What is this even supposed to mean?
17+
// Maybe this whole tower of abstractions wasn't such a good idea after all
18+
// .show()
19+
}
20+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package edu.mcgill.kaliningraph.experimental
2+
3+
import org.junit.jupiter.api.Assertions.assertTrue
4+
import org.junit.jupiter.api.Test
5+
6+
class CyclicalReferenceTest {
7+
@Test
8+
fun testCyclicalReference() {
9+
val owl = Owl { Egg { this } }
10+
println(owl)
11+
println(owl.egg)
12+
println(owl.egg.owl)
13+
println(owl.egg.owl.egg)
14+
assertTrue(owl === owl.egg.owl)
15+
assertTrue(owl.egg === owl.egg.owl.egg)
16+
}
17+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package edu.mcgill.kaliningraph.experimental
2+
3+
import org.junit.jupiter.api.Assertions.assertTrue
4+
import org.junit.jupiter.api.Test
5+
6+
class DoublyLinkedListTest {
7+
@Test
8+
fun testDLL() {
9+
var head = DLL("a").let { ('c'..'f').fold(it) { a, b -> a + b.toString() } }
10+
// println(head)
11+
assertDLL(head)
12+
13+
head = head.insert("b")
14+
println(head + head)
15+
assertDLL(head)
16+
println(head.reversed())
17+
}
18+
19+
private fun assertDLL(head: DLL<String>) =
20+
(1 until head.size - 1).map { head[it] }.forEach {
21+
val isDLLForward = it.next.prev === it
22+
val isDLLBack = it.prev.next === it
23+
println(head)
24+
assertTrue(isDLLForward) { "${it.next.prev} != $it" }
25+
assertTrue(isDLLBack) { "${it.prev.next} != $it" }
26+
}
27+
}

0 commit comments

Comments
 (0)