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 = @"
str = ""test""
return str
";
var evaluated = Executor.EvaluateScript<string>(input, Options);
Assert.Equal("test", evaluated);
}
[Fact]
public void StringIndexable()
{
const string input = @"
str = ""test""
return str[3]
";
var evaluated = Executor.EvaluateScript<string>(input, Options);
Assert.Equal("s", evaluated);
}
[Fact]
public void StringAddition()
{
const string input = @"
str = ""test"" + ""123""
return str
";
var evaluated = Executor.EvaluateScript<string>(input, Options);
Assert.Equal("test123", evaluated);
}
}
}