Professional Documents
Culture Documents
Lexer +
Lexer +
Lexer +
use ExUnit.Case
# doctest Lexer
###################################################################################
###
IO.puts("Pruebas del lexer (7 pruebas Validas del Nora Sandler) ")
test "1.- Elementos separadas espacios ", state do
assert Lexer.scan_words(["int", "main(){return", "2;}"]) == state[:tokens_0] or
state[:tokens]
end
test "2.- Funcion separada del main y el cuerpo del programa", state do
assert Lexer.scan_words(["int", "main()", "{return", "2;}"]) == state[:tokens]
or
state[:tokens_0]
end
test "5.- Con saltos de linea en int y main usando sanitizer", state do
assert "int\nmain\n()\n{return 0;}" |> Sanitizer.sanitize_source() |>
Lexer.scan_words() ==
state[:tokens] or state[:tokens_0]
end
test "7.- Con espacios entre los caracteres en todo usando sanitizer", state do
assert "int main ( ) { return 0 ; } "
|> Sanitizer.sanitize_source()
|> Lexer.scan_words() ==
state[:tokens] or state[:tokens_0]
end
###################################################################################
###
IO.puts("Pruebas no validas")