Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into fix-#1904-dynamic-diag…
Browse files Browse the repository at this point in the history
…ram-inside-describe
  • Loading branch information
fdodino committed Aug 11, 2020
2 parents e57e278 + 90b5807 commit 3d9f511
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 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 @@ -7,8 +7,18 @@ object a {
// XPECT errors --> "Cannot return an assignment" at "ahorro = ahorro * 0.20"
return ahorro = ahorro * 0.20
}

method m1() {
// XPECT errors --> "Cannot return an assignment" at "ahorro += 0.20"
return ahorro += 0.20
}

method m2() {
// XPECT errors --> "Cannot return an assignment" at "ahorro *= 0.20"
return ahorro *= 0.20
}

method m2(param) {
method m3(param) {
ahorro += param
}
}
Expand All @@ -23,6 +33,6 @@ object foo {
}
method bar2() {
// XPECT errors --> "Can't use 'return' expression as argument. Tip: remove 'return' keyword." at "9"
a.m2(return 9)
a.m3(return 9)
}
}
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 @@ -869,6 +869,10 @@ class WollokModelExtensions {
a.fqn == b.fqn || (b.parent !== null && a.isSuperTypeOf(b.parent))
}

static def dispatch isAssignment(WBinaryOperation operation) { operation.isMultiOpAssignment }
static def dispatch isAssignment(WAssignment a) { true }
static def dispatch isAssignment(EObject o) { false }

// ************************************************************************
// ** Compound assignments (+=, -=, *=, /=)
// ************************************************************************
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 Expand Up @@ -1225,7 +1225,7 @@ class WollokDslValidator extends AbstractConfigurableDslValidator {
@DefaultSeverity(ERROR)
@NotConfigurable
def cannotReturnAssignment(WReturnExpression it) {
if (expression !== null && expression instanceof WAssignment)
if (expression !== null && expression.isAssignment)
report(WollokDslValidator_CANNOT_RETURN_ASSIGNMENT, it, WRETURN_EXPRESSION__EXPRESSION)
}

Expand Down

0 comments on commit 3d9f511

Please sign in to comment.