LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Blogs > astrogeek
User Name
Password

Notices


Rate this Entry

Test Cases: Multi-line Input

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

This post is part of the Alphanumeric Calculator program group.

Test cases to validate multi-line input expressions.

By design a single expression is terminated by a line break. But you may enter expressions which span multiple lines by escaping the line break with a backslash as the last character before the line break similar to the usage in C preprocessor macro definitions, among others.

Test cases input file:

Code:
cat tests_multiline
######### An example of an extended multi-line parenthetic expression ########
######### Which holds the answer to life, the universe and everything ########
((one million seven hundred and ten thousand plus\
three hundred seven thousand minus\
(two million one hundred eighty eight thousand four hundred\
over twelve)\
minus two times one million)\
times three thousand three hundred and thirty three\
divided by (fifteen thousand seven hundred and six plus (two hundred over four))\
times eleven) over negative nine thousand one hundred and sixty one
######## Errors should still correctly report line and character #############
one million \
three hundred \
thousand eleven hundred seven
And the results using Rev.3 lexer/parser as posted to this blog.

Code:
./alphacalc tests_multiline -c
######### An example of an extended multi-line parenthetic expression ########
######### Which holds the answer to life, the universe and everything ########
forty two
######## Errors should still correctly report line and character #############
tests_multiline:14.17-14.23: error: syntax error
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 03:22 PM.

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