Skip to content

Commit

Permalink
Increase coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Thihup committed May 22, 2024
1 parent 905aabd commit 973b4de
Show file tree
Hide file tree
Showing 22 changed files with 466 additions and 133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@

public class ExamplesBase {

static Stream<Path> examplesV25() throws Throwable {
public static Stream<Path> examplesV25() throws Throwable {
return examples("v25");
}

static Stream<Path> examplesV30() throws Throwable {
public static Stream<Path> examplesV30() throws Throwable {
return examples("v30");
}

static Stream<Path> examplesCustom() throws Throwable {
public static Stream<Path> examplesCustom() throws Throwable {
return examples("custom");
}
public static Stream<Path> examplesErrors() throws Throwable {
return examples("errors");
}


public static Stream<Path> examples(String folder) throws Throwable {
URI start = ExamplesBase.class.getResource(folder).toURI();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
algoritmo "coverage"

arquivo "inexistente"

procedimento referencia(var x: logico)
inicio
x <- verdadeiro
fimprocedimento

funcao narrowArguments(x: inteiro): inteiro
inicio
retorne x
fimfuncao

funcao widenArguments(x: real): real
inicio
retorne x
fimfuncao

var

arrayInteiro: vetor[1..10] de inteiro
matrizInteiro: vetor[1..2,1..2] de inteiro

arrayReal: vetor[1..10] de real
matrizReal: vetor[1..2,1..2] de real


arrayLogico: vetor[1..10] de logico
matrizLogico: vetor[1..2,1..2] de logico


arrayCaracter: vetor[1..10] de caracter
matrizCaracter: vetor[1..2,1..2] de caracter


flutuante: real

meuInteiro: inteiro
meuReal: real
meuCaracter: caracter
meuLogico: logico

inicio

aleatorio on

mudaCor("VERMELHO", "FRENTE")
mudaCor("Amarelo", "FUNDOS")
mudaCor("azul", "FRENTE")
mudaCor("branco", "FUNDOS")
mudaCor("preto", "FUNDOS")
mudaCor("verde", "FUNDOS")

flutuante <- pi
meuInteiro <- narrowArguments(flutuante)
escreval(meuInteiro)

meuReal <- widenArguments(12)
escreval(meuReal)
meuReal <- widenArguments(meuInteiro)

leia(arrayInteiro[1])
leia(matrizInteiro[1,2])

escreval(arrayInteiro[1])
escreval(matrizInteiro[1,2])

arrayInteiro[1] <- 5
matrizInteiro[1,2] <- 10

arrayReal[1] <- arrayInteiro[1]
matrizReal[1, 2] <- arrayInteiro[1]

meuReal <- 2 ^ 5

debug 1 < 1

referencia(meuLogico)

escreval(+meuInteiro)
escreval(+meuReal)

escolha arrayInteiro[1] faca
caso 4
escreval("Nao aparecer")
caso 5
escreval("Apareci")
fimescolha

escolha matrizInteiro[1,2] faca
caso 1 ate 3
escreval("Nao aparecer")
caso 4 ate 10
escreval("Apareci")
fimescolha

leia(meuCaracter)
leia(meuLogico)
leia(meuInteiro)
leia(meuReal)

fimalgoritmo
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@ VAR

inicio

aleatorio on

leia(A.x)
leia(B.x)
leia(C[0].x)
leia(D[0].x)

escreval(A.x)

escreval(B.x)

escreval(C[0].x)

escreval(D[0].x)

A.x <- 4
B.x <- 1
C[0].x <- 3
D[0].x <- 8

escreval(A.x)

escreval(B.x)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
algoritmo "erro argumento procedimento"

procedimento proc(teste: inteiro)
inicio
fimprocedimento

inicio

proc("a")

fimalgoritmo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
algoritmo "erro atribuicao"

var
teste: vetor[1..1] de inteiro

inicio

teste[1] <- "a"

fimalgoritmo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
algoritmo "erro atribuicao"

var
teste: inteiro

inicio

teste <- "a"

fimalgoritmo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
algoritmo "erro argumento procedimento"

var
x: vetor[1..2] de inteiro

inicio

escreval(x[5])

fimalgoritmo
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
algoritmo "erro add logico"

inicio

escreval(verdadeiro + "s")

fimalgoritmo
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
algoritmo "erro funcao nao existe"

inicio

escreval(oi())

fimalgoritmo
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
algoritmo "erro procedimento nao existe"

inicio

oi()

fimalgoritmo
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
algoritmo "erro tipo nao existe"

var
x: vetor[1..1] de inexistente
inicio

fimalgoritmo
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
algoritmo "erro tipo nao existe"

var
x: inexistente
inicio

fimalgoritmo
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
algoritmo "erro variavel nao existe"

inicio

oi <- 5

fimalgoritmo
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
algoritmo "erro variavel nao existe"

inicio

escreval(oi)

fimalgoritmo
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
algoritmo "erro dentro funcao padrao"

inicio

escreval(randi(-1))

fimalgoritmo
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
algoritmo "erro argumento procedimento"

procedimento proc(teste: inteiro; foo: real)
inicio
fimprocedimento

inicio

proc("a")

fimalgoritmo
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
algoritmo "erro procedimento funcao abs"


inicio

escreval(abs(-30,20))

fimalgoritmo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
algoritmo "erro procedimento mudacor"


inicio

mudaCor("aaa", "fundos")
mudaCor("vermelho", "aaa")
mudaCor("a")

fimalgoritmo
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,9 @@ public ExpressionNode visitExpr(VisuAlgParser.ExprContext ctx) {
if (ctx.parenExpression() instanceof VisuAlgParser.ParenExpressionContext parenExpressionContext) {
return visitExpr(parenExpressionContext.expr());
}
if (ctx.ADD() != null && ctx.expr().size() == 1) {
return new PosNode(visitExpr(ctx.expr(0)), fromRuleContext(ctx));
}
if (ctx.SUB() != null && ctx.expr().size() == 1) {
return new NegNode(visitExpr(ctx.expr(0)), fromRuleContext(ctx));
}
Expand Down
Loading

0 comments on commit 973b4de

Please sign in to comment.