Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ protected virtual void Assign()
{
"-" => -Convert.ToDouble(value),
"!" => !Convert.ToBoolean(value),
"~" when value is List<object> list => list.Count,
"~" when value is string @string => @string.Length,
"~" when value is List<object> list => Convert.ToDouble(list.Count),
"~" when value is string @string => Convert.ToDouble(@string.Length),
"" => value,
_ => throw new NotSupportedException($"_operator {_operator} is not supported")
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using HydraScript.Infrastructure;

namespace HydraScript.IntegrationTests.SuccessPrograms;

public class ArithmeticTests(TestHostFixture fixture) : IClassFixture<TestHostFixture>
{
/// <summary>
/// https://github.com/Stepami/hydrascript/issues/232
/// </summary>
[Fact]
public void Equality_AdditionToTheLeft_Success()
{
const string script =
"""
let i = 0
const s = "abcdef"
const sLen = ~s
while (i < sLen) {
if (i + 1 == sLen)
>>> "i is 5"
i = i + 1
}
""";
using var runner = fixture.GetRunner(
new TestHostFixture.Options(
InMemoryScript: script));
var code = runner.Invoke();
code.Should().Be(Executor.ExitCodes.Success);
fixture.LogMessages.Should()
.Contain(log => log.Contains("i is 5"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Microsoft.Extensions.DependencyInjection;
using NSubstitute;

namespace HydraScript.IntegrationTests;
namespace HydraScript.IntegrationTests.SuccessPrograms;

public class DumpOptionTests(TestHostFixture fixture) : IClassFixture<TestHostFixture>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Microsoft.Extensions.DependencyInjection.Extensions;
using NSubstitute;

namespace HydraScript.IntegrationTests;
namespace HydraScript.IntegrationTests.SuccessPrograms;

public class InputTests(TestHostFixture fixture) : IClassFixture<TestHostFixture>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using HydraScript.Infrastructure;

namespace HydraScript.IntegrationTests;
namespace HydraScript.IntegrationTests.SuccessPrograms;

public class SuccessfulProgramsTests(TestHostFixture fixture) : IClassFixture<TestHostFixture>
{
Expand Down
Loading