-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is similar to `include`, but supports specifying an environment. Also adds `current-environment` and `mutable-environment` methods to (colibri base) for assistance in testing this feature, as well as a lexer bug is fixed in the REPL.
- Loading branch information
Showing
5 changed files
with
117 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using Colibri.Core; | ||
|
||
namespace Colibri.Tests; | ||
|
||
public class LoadTests | ||
{ | ||
[Fact] | ||
public void LoadDefaultEnvironmentTest() | ||
{ | ||
const string program = @" | ||
(with-output-to-file ""test.txt"" | ||
(lambda () | ||
(display ""(define xyz 42)"") | ||
(newline))) | ||
(load ""test.txt"") | ||
(define result xyz) | ||
(delete-file ""test.txt"") | ||
result | ||
"; | ||
|
||
var runtime = new ColibriRuntime(); | ||
|
||
var result = runtime.EvaluateProgram(program); | ||
|
||
Assert.Equal(42, result); | ||
} | ||
|
||
[Fact] | ||
public void LoadSpecifiedEnvironment() | ||
{ | ||
// HACK.PI: uses (colibri base) method (mutable-environment) | ||
const string program = @" | ||
(with-output-to-file ""test.txt"" | ||
(lambda () | ||
(display ""(define xyz 42)"") | ||
(newline))) | ||
(define e (mutable-environment '(scheme base))) | ||
(load ""test.txt"" e) | ||
(define result (eval 'xyz e)) | ||
(delete-file ""test.txt"") | ||
result | ||
"; | ||
|
||
var runtime = new ColibriRuntime(); | ||
|
||
var result = runtime.EvaluateProgram(program); | ||
|
||
Assert.Equal(42, result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters