Skip to content

Commit

Permalink
Test corner cases of stream aliasing
Browse files Browse the repository at this point in the history
  • Loading branch information
adri326 committed Feb 6, 2025
1 parent d8213e2 commit 2a218f3
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/tests/stream-aliasing.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
% NOTE: the tests in this file will need to be changed once
% `open(stream(S1), read, _, NewOptions)` creates a new stream handle `S2` instead of updating
% the options in `S1`. In that case, that specific query will need to be updated
% to instead change the options of `S1`.

alias_dropped_stream :-
open("README.md", read, S, [alias(readme)]),
open(stream(S), read, _, [alias(not_readme)]),
close(S),
stream_property(readme, file_name(_)). % Should throw an existence_error

realias_user_output :-
current_output(S),
open(stream(S), read, _, [alias(not_user_output)]),
stream_property(S, alias(user_output)). % Should succeed

set_output_alias :-
set_output(user_error),
write(user_output, hello). % Should write into stderr, not stdout
2 changes: 2 additions & 0 deletions tests/scryer/cli/src_tests/alias_dropped_stream.stdin
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alias_dropped_stream.
halt.
1 change: 1 addition & 0 deletions tests/scryer/cli/src_tests/alias_dropped_stream.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
error(existence_error(stream,readme),stream_property/0).
2 changes: 2 additions & 0 deletions tests/scryer/cli/src_tests/alias_dropped_stream.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Part of issue 2806
args = ["-f", "--no-add-history", "src/tests/stream-aliasing.pl"]
2 changes: 2 additions & 0 deletions tests/scryer/cli/src_tests/realias_user_output.stdin
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
realias_user_output.
halt.
1 change: 1 addition & 0 deletions tests/scryer/cli/src_tests/realias_user_output.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
true.
2 changes: 2 additions & 0 deletions tests/scryer/cli/src_tests/realias_user_output.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Part of issue 2806
args = ["-f", "--no-add-history", "src/tests/stream-aliasing.pl"]
1 change: 1 addition & 0 deletions tests/scryer/cli/src_tests/set_output_alias.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello true.
2 changes: 2 additions & 0 deletions tests/scryer/cli/src_tests/set_output_alias.stdin
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
set_output_alias.
halt.
2 changes: 2 additions & 0 deletions tests/scryer/cli/src_tests/set_output_alias.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Part of issue 2806
args = ["-f", "--no-add-history", "src/tests/stream-aliasing.pl"]

0 comments on commit 2a218f3

Please sign in to comment.