Skip to content

Commit

Permalink
Merge branch 'dev' into dev-1150-fix-delegate-constructor-to-super
Browse files Browse the repository at this point in the history
  • Loading branch information
tesonep committed Jul 28, 2017
2 parents 334f809 + e2ad694 commit 323faf1
Show file tree
Hide file tree
Showing 76 changed files with 1,755 additions and 774 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ changelog.txt
CHANGELOG.md
xtend-gen
eclipse
.classpath
.project
43 changes: 26 additions & 17 deletions org.uqbar.project.wollok.lib/src/wollok/lang.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,15 @@ class Dictionary {
* @noInstantiate
*/
class Number {
method +(other)
method -(other)
method *(other)
method /(other)

method >(other)
method >=(other)
method <(other)
method <=(other)

/**
* Answers the greater number between two
Expand Down Expand Up @@ -1081,10 +1090,10 @@ class Integer inherits Number {
*/
override method ===(other) native

method +(other) native
method -(other) native
method *(other) native
method /(other) native
override method +(other) native
override method -(other) native
override method *(other) native
override method /(other) native

/** Integer division between self and other
*
Expand Down Expand Up @@ -1119,10 +1128,10 @@ class Integer inherits Number {
*/
method ..(end) = new Range(self, end)

method >(other) native
method >=(other) native
method <(other) native
method <=(other) native
override method >(other) native
override method >=(other) native
override method <(other) native
override method <=(other) native

/**
* Answers absolute value of self
Expand Down Expand Up @@ -1212,11 +1221,11 @@ class Double inherits Number {
/** the whole wollok identity impl is based on self method */
override method ===(other) native

method +(other) native
method -(other) native
method *(other) native
method /(other) native
override method +(other) native
override method -(other) native
override method *(other) native
override method /(other) native

/** Integer division between self and other
*
* Example:
Expand All @@ -1242,10 +1251,10 @@ class Double inherits Number {
/** Self as a String value. Equivalent: toString() */
override method stringValue() native

method >(other) native
method >=(other) native
method <(other) native
method <=(other) native
override method >(other) native
override method >=(other) native
override method <(other) native
override method <=(other) native

/**
* Answers absolute value of self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package org.uqbar.project.wollok.tests.typesystem

import com.google.inject.Inject
import com.google.inject.Injector
import org.apache.log4j.Level
import org.apache.log4j.Logger
import org.eclipse.emf.common.util.Diagnostic
import org.eclipse.emf.ecore.EObject
import org.eclipse.xtend.lib.annotations.Accessors
Expand Down Expand Up @@ -59,6 +61,7 @@ abstract class AbstractWollokTypeSystemTestCase extends AbstractWollokParameteri
@Before
def void setupTypeSystem() {
WollokResourceCache.clearCache
Logger.getLogger(TypeSystem.package.name).level = Level.DEBUG

tsystem = tsystemClass.newInstance
injector.injectMembers(tsystem)
Expand Down Expand Up @@ -218,7 +221,7 @@ abstract class AbstractWollokTypeSystemTestCase extends AbstractWollokParameteri
def findMethod(String methodFQN) {
val fqn = methodFQN.split('\\.')
val m = WMethodContainer.find(fqn.get(0)).methods.findFirst[name == fqn.get(1)]
if (m == null)
if (m === null)
throw new RuntimeException("Could NOT find method " + methodFQN)
m
}
Expand All @@ -231,7 +234,7 @@ abstract class AbstractWollokTypeSystemTestCase extends AbstractWollokParameteri
def <T extends EObject> find(Class<T> resourceType, String resourceName) {
val resources = resourceSet.allContents.filter(resourceType).toList
resources.findFirst[it.name == resourceName] => [
if (it == null)
if (it === null)
throw new RuntimeException(
'''Could NOT find «resourceType.simpleName» [«resourceName»] in: «resources.map[it.name].toList»''')
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package org.uqbar.project.wollok.tests.typesystem
import org.junit.Test
import org.junit.runners.Parameterized.Parameters
import org.uqbar.project.wollok.typesystem.constraints.ConstraintBasedTypeSystem
import org.uqbar.project.wollok.typesystem.substitutions.SubstitutionBasedTypeSystem

/**
* Test cases for type inference of closures.
Expand All @@ -15,7 +14,7 @@ class ClosureInferenceTestCase extends AbstractWollokTypeSystemTestCase {
@Parameters(name="{index}: {0}")
static def Object[] typeSystems() {
#[
SubstitutionBasedTypeSystem,
// SubstitutionBasedTypeSystem,
// ,XSemanticsTypeSystem
ConstraintBasedTypeSystem
// ,BoundsBasedTypeSystem
Expand All @@ -40,7 +39,7 @@ class ClosureInferenceTestCase extends AbstractWollokTypeSystemTestCase {
const c = { a => 2 + a }
}
'''.parseAndInfer.asserting [
assertTypeOfAsString("(Integer) => Integer", "c")
assertTypeOfAsString("(Number) => Number", "c")
]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,14 @@ class InheritanceTypeInferenceTestCase extends AbstractWollokTypeSystemTestCase
}
'''.parseAndInfer.asserting [
noIssues
assertMethodSignature("() => Animal", 'PerroFactory.createAnimal')
assertMethodSignature("() => Animal", 'AnimalFactory.createAnimal')
assertMethodSignature("() => Gato", 'GatoFactory.createAnimal')
assertMethodSignature("() => Perro", 'PerroFactory.createAnimal')
]
}

@Test
@Ignore
def void testAbstractMethodParameterInferredFromOverridingMethodsInSubclassesWithBasicTypes() {
'''
class NumberOperation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import static org.uqbar.project.wollok.sdk.WollokDSK.*
* Just a way to start splitting tests into several classes
*
* @author jfernandes
* @author npasserini
*/
class MethodTypeInferenceTestCase extends AbstractWollokTypeSystemTestCase {

Expand All @@ -35,7 +36,7 @@ class MethodTypeInferenceTestCase extends AbstractWollokTypeSystemTestCase {
number = a + b
}
'''.parseAndInfer.asserting [
assertTypeOf(classTypeFor(INTEGER), 'number')
assertTypeOf(classTypeFor(NUMBER), 'number') // TODO Should be Integer?
]
}

Expand All @@ -50,7 +51,7 @@ class MethodTypeInferenceTestCase extends AbstractWollokTypeSystemTestCase {
}
'''.parseAndInfer.asserting [
noIssues
assertMethodSignature("(Integer) => Void", "Golondrina.come")
assertMethodSignature("(Number) => Void", "Golondrina.come")
]
}

Expand Down Expand Up @@ -119,7 +120,7 @@ class MethodTypeInferenceTestCase extends AbstractWollokTypeSystemTestCase {
}
'''.parseAndInfer.asserting [
noIssues
assertMethodSignature("(Integer) => Void", "Golondrina.multiplicarEnergia")
assertMethodSignature("(Number) => Void", "Golondrina.multiplicarEnergia") // TODO Should be Integer?
]
}

Expand Down Expand Up @@ -156,7 +157,7 @@ class MethodTypeInferenceTestCase extends AbstractWollokTypeSystemTestCase {
'''.parseAndInfer.asserting [
noIssues
assertMethodSignature("() => Void", 'Golondrina.volar')
assertMethodSignature("() => Integer", 'Golondrina.gastoPorVolar')
assertMethodSignature("() => Number", 'Golondrina.gastoPorVolar') // TODO Should be Integer?
]
}

Expand All @@ -174,8 +175,8 @@ class MethodTypeInferenceTestCase extends AbstractWollokTypeSystemTestCase {
}
'''.parseAndInfer.asserting [
noIssues
assertMethodSignature("(Integer) => Void", 'Golondrina.comer')
assertMethodSignature("(Integer) => Void", 'GolondrinaIneficiente.comer')
assertMethodSignature("(Number) => Void", 'Golondrina.comer')
assertMethodSignature("(Number) => Void", 'GolondrinaIneficiente.comer')
]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ object fiona {
}

object salvador {
// XPECT type at dinero --> Integer
// TODO Should be Integer?
// XPECT type at dinero --> Number
var dinero = 1200

method compraZapatos() {
Expand Down Expand Up @@ -59,7 +60,6 @@ object pepe {
method tuClienteEs(unCliente) {
cliente = unCliente
}

}


Loading

0 comments on commit 323faf1

Please sign in to comment.