Upsilon/UpsilonTests/GeneralTests/StringTests.cs

55 lines
1.5 KiB
C#

using Upsilon.Evaluator;
using Xunit;
namespace UpsilonTests
{
public class StringTests : TestClass
{
public StringTests(StaticScriptFixture fix) : base(fix)
{
}
[Fact]
public void BasicStringVariable()
{
const string input = @"
string = ""test""
return string
";
var script = new Script(input, BoundScope, StaticScope);
Assert.Empty(script.Diagnostics.Messages);
var evaluated = script.Evaluate<string>();
Assert.Empty(script.Diagnostics.Messages);
Assert.Equal("test", evaluated);
}
[Fact]
public void StringIndexable()
{
const string input = @"
string = ""test""
return string[3]
";
var script = new Script(input, BoundScope, StaticScope);
Assert.Empty(script.Diagnostics.Messages);
var evaluated = script.Evaluate<string>();
Assert.Empty(script.Diagnostics.Messages);
Assert.Equal("s", evaluated);
}
[Fact]
public void StringAddition()
{
const string input = @"
string = ""test"" + ""123""
return string
";
var script = new Script(input, BoundScope, StaticScope);
Assert.Empty(script.Diagnostics.Messages);
var evaluated = script.Evaluate<string>();
Assert.Empty(script.Diagnostics.Messages);
Assert.Equal("test123", evaluated);
}
}
}