Skip to content

Commit

Permalink
Fix #1875 - property validation incorrectly fails for local object in…
Browse files Browse the repository at this point in the history
…side a test (#1911)
  • Loading branch information
fdodino committed Aug 11, 2020
1 parent ee87c5f commit 90b5807
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,13 @@ describe "group of tests" {
const b = new B(m1 = 2)
b.m1(5)
assert.notEquals(5, b.m1())
}
}
}

test "se puede definir una property dentro de un objeto anónimo en un test" {
const objetoConProperty = object {
var property tres = 3
}
assert.equals(3, objetoConProperty.tres())
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -782,10 +782,14 @@ class WMethodContainerExtensions extends WollokModelExtensions {

def static dispatch boolean isPropertyAllowed(WSuite s) { false }
def static dispatch boolean isPropertyAllowed(WProgram p) { false }
def static dispatch boolean isPropertyAllowed(WConstructor c) { false }
def static dispatch boolean isPropertyAllowed(WMethodDeclaration m) { false }
def static dispatch boolean isPropertyAllowed(WClosure c) { false }
def static dispatch boolean isPropertyAllowed(WFixture f) { false }
def static dispatch boolean isPropertyAllowed(WMethodContainer mc) { true }
def static dispatch boolean isPropertyAllowed(EObject o) {
val declaringContext = o.declaringContext
declaringContext !== null && declaringContext.isPropertyAllowed
def static dispatch boolean isPropertyAllowed(EObject o) {
val parent = o.eContainer
parent !== null && parent.isPropertyAllowed
}

def static hasCyclicDefinition(WConstructor it) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ class WollokDslValidator extends AbstractConfigurableDslValidator {
@DefaultSeverity(ERROR)
@NotConfigurable
def propertyOnlyAllowedInMethodContainer(WVariableDeclaration it) {
if (property && (!isPropertyAllowed || isLocal)) {
if (property && !isPropertyAllowed) {
report(WollokDslValidator_PROPERTY_ONLY_ALLOWED_IN_CERTAIN_METHOD_CONTAINERS, it,
WVARIABLE_DECLARATION__PROPERTY, PROPERTY_ONLY_ALLOWED_IN_CERTAIN_METHOD_CONTAINERS)
}
Expand Down

0 comments on commit 90b5807

Please sign in to comment.