Skip to content

Commit 78ba1c8

Browse files
committed
style: use scala3 indentation style
1 parent 25a5578 commit 78ba1c8

File tree

5 files changed

+32
-62
lines changed

5 files changed

+32
-62
lines changed

src/test/scala/io/github/kelvindev15/prolog/core/TestRecursiveStructs.scala

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,65 +9,55 @@ import org.scalatest.matchers.should.Matchers
99
class TestRecursiveStructs extends AnyFunSuite with Matchers:
1010
private val cmpGoal = Conjunction(Atom("X"), Atom("Y"), Atom("Z"))
1111

12-
test("Cannot create a conjunction of goals from no terms") {
13-
assertThrows[IllegalArgumentException] {
12+
test("Cannot create a conjunction of goals from no terms"):
13+
assertThrows[IllegalArgumentException]:
1414
Conjunction.wrapIfNecessary()
15-
}
16-
}
17-
18-
test("A conjunction of goal is a recursive predicate with arity 2 and with ',' as a functor") {
15+
16+
test("A conjunction of goal is a recursive predicate with arity 2 and with ',' as a functor"):
1917
cmpGoal shouldBe a [Term]
2018
cmpGoal.arity shouldBe 2
2119
cmpGoal.functor shouldBe Atom(",")
22-
}
2320

24-
test("Goal conjunction arguments") {
21+
test("Goal conjunction arguments"):
2522
cmpGoal.first shouldBe Atom("X")
2623
cmpGoal.second shouldBe Conjunction(Atom("Y"), Atom("Z"))
27-
}
24+
2825
private val goals = Seq(
2926
Atom("X"),
3027
Conjunction(Atom("X"), Variable("O")),
3128
Variable("Z"),
3229
Conjunction(Constant(1), Constant(2)))
3330
private val linearizationExpectation = goals.take(3) ++ Seq(Constant(1), Constant(2))
3431

35-
test("Compound goal linearized arguments") {
32+
test("Compound goal linearized arguments"):
3633
val complexGoalConjunction = Conjunction(goals *)
3734
complexGoalConjunction.linearizedArguments shouldBe linearizationExpectation
38-
}
3935

40-
test("Disjunction of goals linearized arguments") {
36+
test("Disjunction of goals linearized arguments"):
4137
val complexGoalDisjunction = Disjunction(goals *)
4238
complexGoalDisjunction.linearizedArguments shouldBe linearizationExpectation
43-
}
4439

4540
private val list = PrologList(Atom("a"), Atom("b"), Atom("c"), Atom("d"))
4641

47-
test("PrologList creation") {
42+
test("PrologList creation"):
4843
list shouldBe a [Term]
4944
list.functor shouldBe Atom(".")
5045
list.arity shouldBe 2
5146
list.arguments.head shouldBe Atom("a")
5247
list.arguments.tail.head shouldBe a [PrologList]
53-
}
5448

55-
test("Prolog list arguments") {
49+
test("Prolog list arguments"):
5650
list.linearizedArguments shouldBe Seq("a", "b", "c", "d").map(Atom(_))
57-
}
5851

59-
test("Creation of a prolog list with Cons and Nil") {
52+
test("Creation of a prolog list with Cons and Nil"):
6053
Cons(Atom("a"), Cons(Atom("b"), Cons(Atom("c"), Cons(Atom("d"), Nil)))) shouldBe list
61-
}
62-
63-
test("A list can end also with a variable") {
54+
55+
test("A list can end also with a variable"):
6456
val list = Cons(Atom("a"), Variable("X"))
6557
list shouldBe a [PrologList]
6658
list.linearizedArguments shouldBe Seq(Atom("a"), Variable("X"))
67-
}
6859

69-
test("A list not ending with a variable") {
60+
test("A list not ending with a variable"):
7061
val list = PrologList(Atom("a"), Variable("X"))
7162
list shouldBe Cons(Atom("a"), Cons(Variable("X"), Nil))
7263
assert(list != Cons(Atom("a"), Variable("X")))
73-
}

src/test/scala/io/github/kelvindev15/prolog/core/TestRules.scala

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,18 @@ class TestRules extends AnyFlatSpec with Matchers:
1313
Struct(Atom("father"), Variable("Z"), Variable("Y"))
1414
)
1515

16-
"A rule" can "have a single term body" in {
16+
"A rule" can "have a single term body" in:
1717
Rule(Struct(Atom("edible"), Variable("X")), Struct(Atom("food"), Variable("X"))) shouldBe a [Term]
18-
}
1918

20-
"The functor of a rule" should "be ':-'" in {
19+
"The functor of a rule" should "be ':-'" in:
2120
grandfatherRule.functor shouldBe Atom("':-'")
22-
}
2321

24-
"The arity of a rule" should "be 2" in {
22+
"The arity of a rule" should "be 2" in:
2523
grandfatherRule.arity shouldBe 2
26-
}
2724

28-
"The rule grandfather(X, Y) :- father(X, Z), father(Z, Y)" should "have 2 terms in the linearized version" in {
25+
"The rule grandfather(X, Y) :- father(X, Z), father(Z, Y)" should "have 2 terms in the linearized version" in:
2926
grandfatherRule.body.accept(BinaryToFlatVisitor()) should have size 2
30-
}
3127

32-
it should "have a grandfather(X, Y) as a head" in {
28+
it should "have a grandfather(X, Y) as a head" in:
3329
assert(grandfatherRule.head.isDefined)
3430
grandfatherRule.head.get shouldBe Struct(Atom("grandfather"), Variable("X"), Variable("Y"))
35-
}

src/test/scala/io/github/kelvindev15/prolog/core/TestStructs.scala

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,26 @@ import org.scalatest.matchers.should.Matchers
77

88
class TestStructs extends AnyFlatSpec with Matchers:
99

10-
"A struct" should "be comprised of a functor and a sequence of one ore more arguments" in {
10+
"A struct" should "be comprised of a functor and a sequence of one ore more arguments" in:
1111
Seq(
1212
Struct(Atom("father"), Atom("abraham"), Atom("therach")),
1313
Struct(Atom("sum"), Numeric(2), Numeric(5), Numeric(7))
14-
) foreach {
15-
_ shouldBe a[Term]
16-
}
17-
}
14+
) foreach { _ shouldBe a[Term] }
1815

19-
"The arity of a Struct " should "equal the number of arguments" in {
16+
"The arity of a Struct " should "equal the number of arguments" in:
2017
val args = Seq(Variable("X"), Atom("pasta"), Constant(4.5))
2118
Struct(Atom("order"), args*).arity shouldBe args.size
22-
}
2319

24-
"The functor of the struct equivalent to father(X, X) " should "be the atom father" in {
20+
"The functor of the struct equivalent to father(X, X) " should "be the atom father" in:
2521
Struct(Atom("father"), Variable("X"), Variable("X")).functor shouldBe Atom("father")
26-
}
2722

28-
"Non ground term variables" should "not be empty" in {
23+
"Non ground term variables" should "not be empty" in:
2924
Struct(Atom("likes"), Atom("mario"), Variable("X")).variables shouldEqual Seq(Variable("X"))
3025
Struct(Atom("likes"), Atom("mario"), Struct(Atom("food"), Variable("X"))).variables shouldEqual Seq(Variable("X"))
31-
}
3226

33-
"Only terms with no variables" should "be ground" in {
27+
"Only terms with no variables" should "be ground" in:
3428
val groundTerm = Struct(Atom("likes"), Atom("mario"), Atom("pizza"))
3529
assert(groundTerm.isGround)
3630

3731
val nonGroundTerm = Struct(Atom("likes"), Atom("mario"), Struct(Atom("food"), Variable("X")))
3832
assert(!nonGroundTerm.isGround)
39-
}

src/test/scala/io/github/kelvindev15/prolog/core/TestVariables.scala

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,15 @@ import org.scalatest.matchers.should.Matchers
77

88
class TestVariables extends AnyFlatSpec with Matchers:
99

10-
"_" should "be an anonymous variable" in {
10+
"_" should "be an anonymous variable" in:
1111
assert(Variable("_").isAnonymous)
12-
}
1312

14-
"A variable name" should "be an alphanumerical string beginning with an with an uppercase letter" in {
15-
Seq("X", "X2", "Abraham", "Snake_variable", "_") foreach {
16-
Variable(_) shouldBe a[Variable]
17-
}
13+
"A variable name" should "be an alphanumerical string beginning with an with an uppercase letter" in:
14+
Seq("X", "X2", "Abraham", "Snake_variable", "_") foreach { Variable(_) shouldBe a[Variable] }
1815
Seq("a", "2X", "X$", "A-Y") foreach { name =>
19-
assertThrows[IllegalArgumentException] {
16+
assertThrows[IllegalArgumentException]:
2017
Variable(name)
21-
}
2218
}
23-
}
2419

25-
it should "not be ground" in {
20+
it should "not be ground" in:
2621
assert(!Variable("X").isGround)
27-
}

src/test/scala/io/github/kelvindev15/prolog/core/theory/TestTheory.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,14 @@ import org.scalatest.matchers.should.Matchers
1111
class TestTheory extends AnyFunSuite with BeforeAndAfterAll with Matchers:
1212
private val rule = Rule(Struct(Atom("eatable"), Variable("X")), Struct(Atom("food"), Variable("X")))
1313

14-
test("Adding a rule to a prolog program") {
14+
test("Adding a rule to a prolog program"):
1515
var program = Theory()
1616
program shouldBe empty
1717
program = program add rule
1818
program should have size 1
19-
}
2019

21-
test("Removing a rule from a prolog program") {
20+
test("Removing a rule from a prolog program"):
2221
var program = Theory(rule)
2322
program should have size 1
2423
program = program remove rule
2524
program shouldBe empty
26-
}

0 commit comments

Comments
 (0)