Upsilon/UpsilonTests/GeneralTests/StringTests.cs

47 lines
1.0 KiB
C#
Raw Permalink Normal View History

2018-11-26 15:55:10 +00:00
using Upsilon;
2018-11-19 12:53:44 +00:00
using Upsilon.Evaluator;
using Xunit;
2018-11-23 13:38:45 +00:00
namespace UpsilonTests.GeneralTests
2018-11-19 12:53:44 +00:00
{
2018-11-23 11:55:28 +00:00
public class StringTests : TestClass
2018-11-19 12:53:44 +00:00
{
2018-11-23 11:55:28 +00:00
public StringTests(StaticScriptFixture fix) : base(fix)
{
}
2018-11-19 12:53:44 +00:00
[Fact]
public void BasicStringVariable()
{
const string input = @"
str = ""test""
return str
2018-11-19 12:53:44 +00:00
";
2018-11-26 15:55:10 +00:00
var evaluated = Executor.EvaluateScript<string>(input, Options);
2018-11-19 12:53:44 +00:00
Assert.Equal("test", evaluated);
}
[Fact]
public void StringIndexable()
{
const string input = @"
str = ""test""
return str[3]
2018-11-19 12:53:44 +00:00
";
2018-11-26 15:55:10 +00:00
var evaluated = Executor.EvaluateScript<string>(input, Options);
2018-11-19 12:53:44 +00:00
Assert.Equal("s", evaluated);
}
[Fact]
public void StringAddition()
{
const string input = @"
str = ""test"" + ""123""
return str
2018-11-19 12:53:44 +00:00
";
2018-11-26 15:55:10 +00:00
var evaluated = Executor.EvaluateScript<string>(input, Options);
2018-11-19 12:53:44 +00:00
Assert.Equal("test123", evaluated);
}
}
}