meevee98 / PNP

PNP is not Pseudocode
MIT License
0 stars 0 forks source link

Include the semantic of logical operations #6

Closed meevee98 closed 4 years ago

meevee98 commented 4 years ago

Closes #4 I also included some unit tests to Analyser class. I did some modifications in this class because of some methods were having different behaviour from the expected.

Thacryba commented 4 years ago

Hello! It's me again! I was making some tests in this PR and this is what I got: 👍

Tests
AND 1. The result of the operation AND between booleans with value true, assigned into a boolean variable. Expected: It should be no semantic error. Result: The code was translated without semantic errors. 1. The result of the operation AND between booleans with value true and false, assigned into a boolean variable. Expected: It should be no semantic error. Result: The code was translated without semantic errors. 1. The result of the operation AND between booleans with value false, assigned into a boolean variable. Expected: It should be no semantic error. Result: The code was translated without semantic errors. 1. The result of the operation AND between booleans with value false and true, assigned into a boolean variable. Expected: It should be no semantic error. Result: The code was translated without semantic errors. 1. The result of the operation AND between booleans with value true, assigned into a rational variable. Expected: Error Type. Result: `line 8:4 Incompatible types between Rational and Boolean` 1. The result of the operation AND between booleans with value true, assigned into a integer variable. Expected: Error Type. Result: `line 8:4 Incompatible types between Integer and Boolean` 1. The result of the operation AND between booleans with value true, assigned into a character variable. Expected: Error Type. Result: `line 8:4 Incompatible types between Character and Boolean` 1. The result of the operation AND between booleans with value true, assigned into a string variable. Expected: Error Type. Result: `line 8:4 Incompatible types between String and Boolean`
OR 1. The result of the operation OR between booleans with value true, assigned into a boolean variable. Expected: It should be no semantic error. Result: The code was translated without semantic errors. 1. The result of the operation OR between booleans with value true and false, assigned into a boolean variable. Expected: It should be no semantic error. Result: The code was translated without semantic errors. 1. The result of the operation OR between booleans with value false, assigned into a boolean variable. Expected: It should be no semantic error. Result: The code was translated without semantic errors. 1. The result of the operation OR between booleans with value false and true, assigned into a boolean variable. Expected: It should be no semantic error. Result: The code was translated without semantic errors. 1. The result of the operation OR between booleans with value true, assigned into a rational variable. Expected: Error Type. Result: `line 8:4 Incompatible types between Rational and Boolean` 1. The result of the operation OR between booleans with value true, assigned into a integer variable. Expected: Error Type. Result: `line 8:4 Incompatible types between Integer and Boolean` 1. The result of the operation OR between booleans with value true, assigned into a character variable. Expected: Error Type. Result: `line 8:4 Incompatible types between Character and Boolean` 1. The result of the operation OR between booleans with value true, assigned into a string variable. Expected: Error Type. Result: `line 8:4 Incompatible types between String and Boolean`
XOR 1. The result of the operation XOR between booleans with value true, assigned into a boolean variable. Expected: It should be no semantic error. Result: The code was translated without semantic errors. 1. The result of the operation XOR between booleans with value true and false, assigned into a boolean variable. Expected: It should be no semantic error. Result: The code was translated without semantic errors. 1. The result of the operation XOR between booleans with value false, assigned into a boolean variable. Expected: It should be no semantic error. Result: The code was translated without semantic errors. 1. The result of the operation XOR between booleans with value false and true, assigned into a boolean variable. Expected: It should be no semantic error. Result: The code was translated without semantic errors. 1. The result of the operation XOR between booleans with value true, assigned into a rational variable. Expected: Error Type. Result: `line 8:4 Incompatible types between Rational and Boolean` 1. The result of the operation XOR between booleans with value true, assigned into a integer variable. Expected: Error Type. Result: `line 8:4 Incompatible types between Integer and Boolean` 1. The result of the operation XOR between booleans with value true, assigned into a character variable. Expected: Error Type. Result: `line 8:4 Incompatible types between Character and Boolean` 1. The result of the operation XOR between booleans with value true, assigned into a string variable. Expected: Error Type. Result: `line 8:4 Incompatible types between String and Boolean`
NOT 1. The result of the operation NOT with a boolean with value true, assigned into a boolean variable. Expected: It should be no semantic error. Result: The code was translated without semantic errors. 1. The result of the operation NOT with a boolean with value false, assigned into a boolean variable. Expected: It should be no semantic error. Result: The code was translated without semantic errors. 1. The result of the operation NOT with a boolean with value true, assigned into a rational variable. Expected: Error Type. Result: `line 8:4 Incompatible types between Rational and Boolean` 1. The result of the operation NOT with a boolean with value false, assigned into a rational variable. Expected: Error Type. Result: `line 8:4 Incompatible types between Rational and Boolean` 1. The result of the operation NOT with a boolean with value true, assigned into a integer variable. Expected: Error Type. Result: `line 8:4 Incompatible types between Integer and Boolean` 1. The result of the operation NOT with a boolean with value false, assigned into a integer variable. Expected: Error Type. Result: `line 8:4 Incompatible types between Integer and Boolean` 1. The result of the operation NOT with a boolean with value true, assigned into a character variable. Expected: Error Type. Result: `line 8:4 Incompatible types between Character and Boolean` 1. The result of the operation NOT with a boolean with value false, assigned into a character variable. Expected: Error Type. Result: `line 8:4 Incompatible types between Character and Boolean` 1. The result of the operation NOT with a boolean with value true, assigned into a string variable. Expected: Error Type. Result: `line 8:4 Incompatible types between String and Boolean` 1. The result of the operation NOT with a boolean with value false, assigned into a string variable. Expected: Error Type. Result: `line 8:4 Incompatible types between String and Boolean`
Some variations of this code were used in the test: ``` procedimento principal inicio var1: booleano; var1 <- true; var2: booleano; var2 <- true; var3: booleano; var3 <- var1 e var2; fim ```

Until next time!