diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8e84736 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9e95028 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ + +# Local history +.history + +# Wollok Log +*.log diff --git a/README.md b/README.md new file mode 100644 index 0000000..76b305e --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ + + +## example + +TODO + diff --git a/intensa.wlk b/intensa.wlk new file mode 100644 index 0000000..7648ac0 --- /dev/null +++ b/intensa.wlk @@ -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 +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..adf41ca --- /dev/null +++ b/package.json @@ -0,0 +1,7 @@ +{ + "name": "intensamente", + "version": "1.0.0", + "wollokVersion": "4.0.0", + "author": "lucas", + "license": "ISC" +} diff --git a/test.wtest b/test.wtest new file mode 100644 index 0000000..8899189 --- /dev/null +++ b/test.wtest @@ -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()) + + } +} \ No newline at end of file