From fc84b5c2b7223a31e0dce7664bc1e017f862d89e Mon Sep 17 00:00:00 2001 From: Matthew Harrigan Date: Sat, 29 May 2021 13:17:51 -0700 Subject: [PATCH] added SLEEP tests and support for python expressions in the SLEEP statement --- shepherd/Tester.py | 4 +-- shepherd/tests/TESTING_DOCS.md | 4 +-- .../tests/testing_tests/sleep_test.shepherd | 25 +++++++++++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 shepherd/tests/testing_tests/sleep_test.shepherd diff --git a/shepherd/Tester.py b/shepherd/Tester.py index 30eedfde..590df029 100644 --- a/shepherd/Tester.py +++ b/shepherd/Tester.py @@ -374,10 +374,10 @@ def sleep_function(expression): if expression == '': raise Exception('expected a time afer after SLEEP') try: - amount = float(expression) + amount = float(evaluate_python(expression)) except ValueError as e: raise Exception(f'expected a time afer after SLEEP, but got {expression}') - time.Sleep(amount) + time.sleep(amount) def read_function(line): """ diff --git a/shepherd/tests/TESTING_DOCS.md b/shepherd/tests/TESTING_DOCS.md index 549b1293..8a053eb5 100644 --- a/shepherd/tests/TESTING_DOCS.md +++ b/shepherd/tests/TESTING_DOCS.md @@ -62,9 +62,9 @@ Usage: `PRINTP ` The SLEEP statement is used in order to pause the execution of the .shepherd interpreter for a specified amount of time. Any LCM messages received while the interpreter is paused will still be recorded and may be processed by the next WAIT statement that the interpreter encounters. The sleep -time may be a decimal, and is in terms of seconds. +time may be a decimal, and is in terms of seconds. SLEEP may take a python expression as an argument, so long as it evaluates to a float. -Usage: `SLEEP