Upsilon/UpsilonTests/GeneralTests/StringTests.cs

47 lines
1.0 KiB
C#

using Upsilon;
using Upsilon.Evaluator;
using Xunit;
namespace UpsilonTests.GeneralTests
{
public class StringTests : TestClass
{
public StringTests(StaticScriptFixture fix) : base(fix)
{
}
[Fact]
public void BasicStringVariable()
{
const string input = @"
string = ""test""
return string
";
var evaluated = Executor.EvaluateScript<string>(input, Options);
Assert.Equal("test", evaluated);
}
[Fact]
public void StringIndexable()
{
const string input = @"
string = ""test""
return string[3]
";
var evaluated = Executor.EvaluateScript<string>(input, Options);
Assert.Equal("s", evaluated);
}
[Fact]
public void StringAddition()
{
const string input = @"
string = ""test"" + ""123""
return string
";
var evaluated = Executor.EvaluateScript<string>(input, Options);
Assert.Equal("test123", evaluated);
}
}
}