Skip to content

Commit

Permalink
Merge pull request #172 from uqbar-project/fix-#211-shouldImplementAl…
Browse files Browse the repository at this point in the history
…lMethodsInHierarchy

Fix should implement all methods in hierarchy
  • Loading branch information
PalumboN authored Feb 28, 2024
2 parents 5d21abd + af47869 commit 843f73c
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions test/validations/shouldImplementAllMethodsInHierarchy.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ mixin M4 {
}

//
// Mixin Calling super() mixed in differnt combination
// Mixin Calling super() mixed in different combination
// checks for super implementation present
//
mixin Doctor {
override method name() = "Dr. " + super()
}

@Expect(code = "shouldImplementAllMethodsInHierarchy", level = "error")
@Expect(code = "shouldImplementAllMethodsInHierarchy", level = "error", expectedOn="Tomato")
class Tomato inherits Doctor {}

@Expect(code = "shouldImplementAllMethodsInHierarchy", level = "error")
@Expect(code = "shouldImplementAllMethodsInHierarchy", level = "error", expectedOn="TomatoWithNameBelowSuper")
class TomatoWithNameBelowSuper inherits Doctor {
override method name() = "23"
}
Expand All @@ -67,7 +67,7 @@ mixin Named {
class Person inherits Doctor and Named {}

// NOT OK ! order matters !
@Expect(code = "shouldImplementAllMethodsInHierarchy", level = "error")
@Expect(code = "shouldImplementAllMethodsInHierarchy", level = "error", expectedOn="PersonBad")
class PersonBad inherits Named and Doctor {}

// OK: super method comes from super class
Expand All @@ -77,7 +77,7 @@ class WithName {
class ANamed inherits Doctor and WithName {
}

@Expect(code = "shouldImplementAllMethodsInHierarchy", level = "error")
@Expect(code = "shouldImplementAllMethodsInHierarchy", level = "error", expectedOn="o1")
object o1 inherits Doctor {
}

Expand All @@ -88,7 +88,7 @@ object o2 inherits Doctor and WithName {
// OK
object o3 inherits Doctor and Named {}

@Expect(code = "shouldImplementAllMethodsInHierarchy", level = "error")
@Expect(code = "shouldImplementAllMethodsInHierarchy", level = "error", expectedOn="o4")
object o4 inherits Named and Doctor {}


Expand All @@ -103,13 +103,30 @@ object mixingAtInstantiation {
return [
// OK
object inherits Doctor and WithName {},
@Expect(code = "shouldImplementAllMethodsInHierarchy", level = "error")
@Expect(code = "shouldImplementAllMethodsInHierarchy", level = "error", expectedOn="object inherits Doctor {}")
object inherits Doctor {},

// OK
object inherits Doctor and Named and Pepin {},
@Expect(code = "shouldImplementAllMethodsInHierarchy", level = "error")
@Expect(code = "shouldImplementAllMethodsInHierarchy", level = "error", expectedOn="object inherits Named and Doctor and Pepin {}")
object inherits Named and Doctor and Pepin {}
]
}
}

// Superclass with an abstract method
class Superclass {
method myMethod(someParameter)
}

// Concrete class should not call to super if method in superclass is abstract
@Expect(code = "shouldImplementAllMethodsInHierarchy", level = "error", expectedOn="ConcreteClass")
class ConcreteClass inherits Superclass {

method doStuff() {}

override method myMethod(someParameter) {
self.doStuff()
super(someParameter)
}
}

0 comments on commit 843f73c

Please sign in to comment.