-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
318 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
...bar.project.wollok.tests/src/org/uqbar/project/wollok/tests/typesystem/xpect/super.wlk.xt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/* XPECT_SETUP org.uqbar.project.wollok.tests.typesystem.xpect.TypeSystemXpectTestCase END_SETUP */ | ||
|
||
class Ave { | ||
// XPECT type at nombre --> String | ||
var nombre | ||
var energia = 100 | ||
|
||
// XPECT type at nom --> String | ||
constructor(nom) { | ||
nombre = nom | ||
} | ||
|
||
constructor() = self("") { } | ||
|
||
// XPECT methodType at come --> (Number) => Void | ||
method come(gramos) { | ||
energia = energia + gramos | ||
} | ||
|
||
// XPECT methodType at energia --> () => Number | ||
method energia() = energia | ||
} | ||
|
||
class Golondrina inherits Ave { | ||
|
||
// XPECT type at e2 --> Number | ||
constructor(e2) = super("pepita") { | ||
self.vola() | ||
} | ||
|
||
constructor() = self(1) { } | ||
|
||
// XPECT methodType at vola --> () => Void | ||
method vola() { | ||
energia = energia - 10 | ||
} | ||
|
||
// XPECT methodType at come --> (Number) => Void | ||
override method come(gramos) { | ||
super(gramos + 10) | ||
} | ||
} | ||
|
||
class GolondrinaMentirosa inherits Golondrina { | ||
|
||
// XPECT type at e3 --> Number | ||
constructor(e3) = super(e3) { | ||
self.vola() | ||
} | ||
|
||
// XPECT methodType at energia --> () => Number | ||
override method energia() = super() + 10 | ||
} | ||
|
||
|
||
|
||
class EntrenadorChanta inherits EntrenadorDeGolondrinas { | ||
// XPECT methodType at alimentar --> (Ave) => Void | ||
override method alimentar(ave) { | ||
super(new GolondrinaMentirosa(1)) | ||
} | ||
|
||
// XPECT methodType at hacerQueVuele --> (Golondrina) => Void | ||
override method hacerQueVuele(golondrina) { | ||
// golondrina.come(1) TODO: Fix it! This can't be an Ave | ||
super(golondrina) | ||
} | ||
|
||
// XPECT methodType at pajaro --> () => GolondrinaMentirosa | ||
override method pajaro() { | ||
// XPECT type at p --> Golondrina | ||
const p = super() | ||
return new GolondrinaMentirosa(1) | ||
} | ||
} | ||
|
||
class EntrenadorDeGolondrinas inherits EntrenadorDeAves { | ||
|
||
// XPECT type at g --> Golondrina | ||
constructor(g) = super(g) { | ||
g.vola() | ||
} | ||
|
||
// XPECT methodType at alimentar --> (Ave) => Void | ||
override method alimentar(ave) { | ||
super(new Golondrina()) | ||
} | ||
|
||
// XPECT methodType at hacerQueVuele --> (Golondrina) => Void | ||
method hacerQueVuele(golondrina) { | ||
golondrina.vola() | ||
} | ||
|
||
// XPECT methodType at pajaro --> () => Golondrina | ||
override method pajaro() { | ||
// XPECT type at a --> Ave | ||
const a = super() | ||
return new Golondrina() | ||
} | ||
|
||
method hacerVolarGolondrina() { self.hacerQueVuele(new Golondrina()) } | ||
} | ||
|
||
class EntrenadorDeAves { | ||
const ave | ||
|
||
// XPECT type at a --> Ave | ||
constructor(a) { | ||
ave = a | ||
} | ||
|
||
// XPECT methodType at alimentar --> (Ave) => Void | ||
method alimentar(ave) { ave.come(10) } | ||
|
||
// XPECT methodType at pajaro --> () => Ave | ||
method pajaro() = new Ave() | ||
|
||
method alimentarAve() { self.alimentar(new Ave()) } | ||
|
||
method alimentarFavorita() { ave.come(1) } | ||
} | ||
|
||
object wollok { | ||
method entrenadorDeAves() = new EntrenadorDeAves(new Ave()) | ||
method entrenadorDeGolondrinas() = new EntrenadorDeGolondrinas(new Golondrina()) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.