51 lines
1.3 KiB
C#
51 lines
1.3 KiB
C#
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);
|
|
}
|
|
|
|
}
|
|
} |