LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Blogs > astrogeek
User Name
Password

Notices


Rate this Entry

Test Cases: Sign

Posted 10-10-2021 at 11:54 PM by astrogeek

This post is part of the Alphanumeric Calculator program group.

Test cases to validate handling of sign.

The test case input file:

Code:
cat tests_sign
#both
############ Numbers with signs
+0
+1
-0
-1
-1*-1
-1*+1
+1*-1
+1*+1
############ Numeric expressions with signs
positive zero
positive one
negative zero
negative one
negative one times negative one
negative one times positive one
positive one times negative one
positive one times positive one
############ Valid multiple but unambiguous sign
1++1
1+-1
1-+1
1--1
############ Invalid multiple or ambiguous sign
1+1
1-1
1+++1
############ Invalid mixed (non-atomic) symbolic/expression sign and magnitude
one plus positive 1
one plus negative 1
one plus +one
one plus -one
############ Invalid expressions - as defined in this grammar
negative negative one
positive positive one
############ Invalid multiple sign, operation not valid at start of line
--1
++1
############ Naked signs - syntax error is reported on END token
negative
positive
And the results using Rev. 3 lexer/parser as posted in this blog:

Code:
./alphacalc tests_sign -c
#both
############ Numbers with signs
zero
one
zero
negative one
one
negative one
negative one
one
############ Numeric expressions with signs
zero
one
zero
negative one
one
negative one
negative one
one
############ Valid multiple but unambiguous sign
two
zero
zero
two
############ Invalid multiple or ambiguous sign
tests_sign:26.2-26.3: error: syntax error
tests_sign:27.2-27.3: error: syntax error
tests_sign:28.3-28.3: error: syntax error
############ Invalid mixed (non-atomic) symbolic/expression sign and magnitude
tests_sign:30.19-30.19: error: syntax error
tests_sign:31.19-31.19: error: syntax error
tests_sign:32.10-32.10: error: syntax error
tests_sign:33.10-33.10: error: syntax error
############ Invalid expressions - as defined in this grammar
tests_sign:35.10-35.17: error: syntax error
tests_sign:36.10-36.17: error: syntax error
############ Invalid multiple sign, operation not valid at start of line
tests_sign:38.1-38.1: error: syntax error
tests_sign:39.1-39.1: error: syntax error
############ Naked signs - syntax error is reported on END token
tests_sign:42.9-42.9: error: syntax error
tests_sign:43.9-43.9: error: syntax error
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 04:45 AM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration