Skip to content

Commit

Permalink
Add test case for non-expansion in string variables
Browse files Browse the repository at this point in the history
  • Loading branch information
thoni56 committed Aug 18, 2019
1 parent 26455d8 commit c498022
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
29 changes: 29 additions & 0 deletions regression/dollar_in_player_input.alan
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
--==============================================================================
-- BUG: String parameters may contain Alan special $ symbols, which can lead to
-- infinite recursion when the player types "$1".
--==============================================================================

THE room IsA LOCATION
Has text "".
VERB write
DOES
"You write ""$1""."
Set text of room to str.
END VERB write.
END THE room.

-- Verb Write
SYNTAX write = write (str)
WHERE str IsA string
ELSE "You can only use strings with this verb."


-- Verb Read
SYNTAX read = read.

VERB read
DOES
Say text of room.
END VERB read.

Start at room.
34 changes: 34 additions & 0 deletions regression/dollar_in_player_input.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
########## dollar_in_player_input ##########

No warnings or errors detected.



Room

> read

> write "Hello world."
You write "Hello world.".

> read
Hello world.

> write "Hello.$pWorld"
You write "Hello.$pWorld".

> read
Hello.$pWorld

> write "Hello.$1"
You write "Hello.$1".

> read
Hello.$1

> write "$1"
You write "$1".

>

Do you want to UNDO, RESTART, RESTORE or QUIT ?
8 changes: 8 additions & 0 deletions regression/dollar_in_player_input.input
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
read
write "Hello world."
read
write "Hello.$pWorld"
read
write "Hello.$1"
read
write "$1"

0 comments on commit c498022

Please sign in to comment.