-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 9085bb8
Showing
6 changed files
with
181 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: build | ||
|
||
on: [push, pull_request] | ||
jobs: | ||
wollok-ts: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: | | ||
wget -O wollok-ts-cli https://github.com/uqbar-project/wollok-ts-cli/releases/latest/download/wollok-ts-cli-linux-x64 | ||
chmod a+x ./wollok-ts-cli | ||
./wollok-ts-cli test --skipValidations -p ./ | ||
shell: bash |
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,6 @@ | ||
|
||
# Local history | ||
.history | ||
|
||
# Wollok Log | ||
*.log |
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,6 @@ | ||
|
||
|
||
## example | ||
|
||
TODO | ||
|
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,96 @@ | ||
object intensamente { | ||
var property intensidadLimite = 10 | ||
const personas = [] | ||
method agregar(p){ | ||
personas.add(p) | ||
} | ||
|
||
method cantidadPorExplotar() = personas.count{p=>p.porExplotar()} | ||
|
||
method todosViven(evento) { | ||
personas.forEach{p=>p.vivir(evento)} | ||
} | ||
} | ||
|
||
class Persona { | ||
var property edad | ||
const emociones = [] | ||
|
||
method esAdolescente() = edad.between(12,19) | ||
|
||
method tenerEmocion(nueva){ | ||
emociones.add(nueva) | ||
} | ||
|
||
method porExplotar() = | ||
emociones.all{e=>e.puedeLiberarse()} | ||
|
||
method vivir(evento){ | ||
emociones.forEach{e=>e.intentarLiberarse(evento)} | ||
} | ||
} | ||
|
||
|
||
class Emocion{ | ||
var cantidadEventos = 0 | ||
var property intensidad | ||
method puedeLiberarse() = | ||
intensidad > intensamente.intensidadLimite() and | ||
self.condicionAdicional() | ||
|
||
method condicionAdicional() | ||
|
||
method intentarLiberarse(evento) { | ||
if(self.puedeLiberarse()) | ||
self.liberarse(evento) | ||
cantidadEventos +=1 | ||
} | ||
method liberarse(evento){ | ||
self.intensidad( intensidad - evento.impacto()) | ||
} | ||
} | ||
class Ansiedad inherits Furia{ | ||
override method liberarse(evento) { } | ||
} | ||
|
||
class Furia inherits Emocion(intensidad=100){ | ||
const palabrotas = [] | ||
override method condicionAdicional() = | ||
palabrotas.any{p=>p.size() >= 7} | ||
override method liberarse(evento){ | ||
super(evento) | ||
palabrotas.remove(palabrotas.first()) | ||
} | ||
method aprender(pal){ | ||
palabrotas.add(pal) | ||
} | ||
} | ||
|
||
class Alegria inherits Emocion{ | ||
override method condicionAdicional() = | ||
cantidadEventos.even() | ||
|
||
override method intensidad(valor){ | ||
intensidad = valor.abs() | ||
} | ||
} | ||
|
||
class Tristeza inherits Emocion { | ||
var property causa = "melancolia" | ||
override method condicionAdicional() = | ||
causa != "melancolia" | ||
override method liberarse(evento){ | ||
super(evento) | ||
causa= evento.descripcion() | ||
} | ||
} | ||
|
||
class OtraEmocion inherits Emocion { | ||
override method condicionAdicional() = | ||
cantidadEventos > intensidad | ||
} | ||
|
||
class Evento{ | ||
var property impacto | ||
var property descripcion | ||
} |
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,7 @@ | ||
{ | ||
"name": "intensamente", | ||
"version": "1.0.0", | ||
"wollokVersion": "4.0.0", | ||
"author": "lucas", | ||
"license": "ISC" | ||
} |
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,52 @@ | ||
import intensa.* | ||
|
||
describe "group of tests " { | ||
const riley = new Persona(edad = 12) | ||
const alegriaR = new Alegria(intensidad=20) | ||
const tristezaR = new Tristeza(intensidad = 70) | ||
|
||
const padre = new Persona(edad = 40) | ||
const alegriaP = new Alegria(intensidad=50) | ||
const otraP = new OtraEmocion(intensidad = 20) | ||
const furiaP = new Furia() | ||
|
||
const partido = new Evento(impacto=10, descripcion="hockey") | ||
test "un adolescente " { | ||
|
||
assert.that( riley.esAdolescente()) | ||
} | ||
|
||
test "por explotar emocionalmente con tristeza por no melancolia" { | ||
tristezaR.causa("escuela") | ||
riley.tenerEmocion(alegriaR) | ||
riley.tenerEmocion(tristezaR) | ||
assert.that(riley.porExplotar()) | ||
} | ||
|
||
test "no esta por explotar emocionalmente con tristeza por melancolia" { | ||
riley.tenerEmocion(alegriaR) | ||
riley.tenerEmocion(tristezaR) | ||
assert.notThat(riley.porExplotar()) | ||
} | ||
|
||
test "un evento es alterador"{ | ||
var cantidad | ||
intensamente.agregar(riley) | ||
riley.tenerEmocion(alegriaR) | ||
riley.tenerEmocion(tristezaR) | ||
tristezaR.causa("escuela") | ||
|
||
intensamente.agregar(padre) | ||
padre.tenerEmocion(alegriaP) | ||
padre.tenerEmocion(furiaP) | ||
padre.tenerEmocion(otraP) | ||
furiaP.aprender("xxxxxxxxxx") | ||
|
||
cantidad = intensamente.cantidadPorExplotar() | ||
|
||
intensamente.todosViven(partido) | ||
|
||
assert.notEquals (cantidad, intensamente.cantidadPorExplotar()) | ||
|
||
} | ||
} |