Upsilon/UpsilonTests/StringTests.cs

51 lines
1.3 KiB
C#
Raw Normal View History

2018-11-19 12:53:44 +00:00
using Upsilon.Evaluator;
using Xunit;
namespace UpsilonTests
{
public class StringTests
{
[Fact]
public void BasicStringVariable()
{
const string input = @"
string = ""test""
return string
";
var script = new Script(input);
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);
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);
Assert.Empty(script.Diagnostics.Messages);
var evaluated = script.Evaluate<string>();
Assert.Empty(script.Diagnostics.Messages);
Assert.Equal("test123", evaluated);
}
}
}