-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
38 additions
and
4 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
32 changes: 32 additions & 0 deletions
32
tests/HydraScript.IntegrationTests/ErrorPrograms/NullAssignmentWhenUndefinedTests.cs
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,32 @@ | ||
using System.CommandLine.Parsing; | ||
|
||
namespace HydraScript.IntegrationTests.ErrorPrograms; | ||
|
||
public class NullAssignmentWhenUndefinedTests(TestHostFixture fixture) : IClassFixture<TestHostFixture> | ||
{ | ||
[Theory, MemberData(nameof(NullAssignmentScripts))] | ||
public void NullAssignment_UndefinedDestinationOrReturnType_HydraScriptError(string script) | ||
{ | ||
var runner = fixture.GetRunner( | ||
configureTestServices: services => | ||
services.SetupInMemoryScript(script)); | ||
var code = runner.Invoke(fixture.InMemoryScript); | ||
code.Should().Be(ExitCodes.HydraScriptError); | ||
fixture.LogMessages.Should() | ||
.Contain(x => x.Contains("Cannot assign 'null' when type is undefined")); | ||
} | ||
|
||
public static TheoryData<string> NullAssignmentScripts | ||
{ | ||
get | ||
{ | ||
const string lexicalDeclaration = "let x = null"; | ||
const string objectLiteralProperty = "let y = {prop: null;}"; | ||
const string functionReturn = "function f() { return null }"; | ||
return new TheoryData<string>([ | ||
lexicalDeclaration, | ||
objectLiteralProperty, | ||
functionReturn]); | ||
} | ||
} | ||
} |
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