Skip to content

Commit

Permalink
Merge 5b53737 into 2f0414f
Browse files Browse the repository at this point in the history
  • Loading branch information
fdodino committed Aug 11, 2018
2 parents 2f0414f + 5b53737 commit 54d586e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* XPECT_SETUP org.uqbar.project.wollok.tests.typesystem.xpect.TypeSystemXpectTestCase END_SETUP */

program p {
const n = 23

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
/* XPECT_SETUP org.uqbar.project.wollok.tests.xpect.WollokXPectTest END_SETUP */

object joaquin {
var tocaEnGrupo = false
var gradoAlegria

// XPECT errors --> "If-statements without else cannot be considered valid expressions as they cannot always yield a value" at "tocaEnGrupo"
method habilidadAdquirida() = if (tocaEnGrupo) 5

// XPECT errors --> "Must return a value on every possible flow" at "felicidad"
method felicidad() {
if (tocaEnGrupo) return 5
}

method inicializar() {
// XPECT errors --> "If-statements without else cannot be considered valid expressions as they cannot always yield a value" at "tocaEnGrupo"
gradoAlegria = if (tocaEnGrupo) 3
}

// XPECT errors --> "If-statements without else cannot be considered valid expressions as they cannot always yield a value" at "tocaEnGrupo"
method felicidadTotal(numero) = numero + if (tocaEnGrupo) 5

method validarFelicidad() {
// XPECT errors --> "If-statements without else cannot be considered valid expressions as they cannot always yield a value" at "tocaEnGrupo"
assert.equals(10, if (tocaEnGrupo) 5)
}

method asignarFelicidadSiCorresponde() {
if (tocaEnGrupo) {
gradoAlegria = gradoAlegria + 10
}
}
}

object sarasita {

method withTheReturnWithinTheBranches(n) {
Expand Down Expand Up @@ -99,4 +131,4 @@ object sarasita {
// XPECT errors --> "If-statements without else cannot be considered valid expressions as they cannot always yield a value" at "1 == 2"
return self.addOneTo(if (1 == 2) 4)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,8 @@ class WollokModelExtensions {
def static dispatch expectsExpression(EObject e) { false }
def static dispatch expectsExpression(WBinaryOperation op) { true }
def static dispatch expectsExpression(WUnaryOperation op) { true }
def static dispatch expectsExpression(WMethodDeclaration m) { m.expressionReturns }
def static dispatch expectsExpression(WAssignment m) { true }
def static dispatch expectsExpression(WReturnExpression r) { true }
def static dispatch expectsExpression(WVariableDeclaration v) { true }
def static dispatch expectsExpression(WMemberFeatureCall c) { true }
Expand Down

0 comments on commit 54d586e

Please sign in to comment.