-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #248 from stevehalliwell/imp
Merge imp into main
- Loading branch information
Showing
9 changed files
with
280 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine; | ||
using NUnit.Framework; | ||
|
||
namespace ULox.Core.Tests | ||
{ | ||
public class StaticClassTests : EngineTestBase | ||
{ | ||
[Test] | ||
public void Engine_Class_StaticField() | ||
{ | ||
testEngine.Run(@" | ||
class T | ||
{ | ||
static var a = 2; | ||
} | ||
print(T.a);"); | ||
|
||
Assert.AreEqual("2", testEngine.InterpreterResult); | ||
} | ||
|
||
[Test] | ||
public void Engine_Class_StaticFields() | ||
{ | ||
testEngine.Run(@" | ||
class T | ||
{ | ||
static var | ||
a = 2, | ||
b = 1, | ||
; | ||
} | ||
print(T.a);"); | ||
|
||
Assert.AreEqual("2", testEngine.InterpreterResult); | ||
} | ||
|
||
[Test] | ||
public void Engine_Class_StaticFields_Modify() | ||
{ | ||
testEngine.Run(@" | ||
class T | ||
{ | ||
static var a = 2; | ||
} | ||
T.a = 1; | ||
print(T.a);"); | ||
|
||
Assert.AreEqual("1", testEngine.InterpreterResult); | ||
} | ||
|
||
[Test] | ||
public void Engine_Class_StaticFields_WhenClassModified_ShouldThrow() | ||
{ | ||
testEngine.Run(@" | ||
class T | ||
{ | ||
static var a = 2; | ||
} | ||
T.b = 5;"); | ||
|
||
StringAssert.StartsWith("Attempted to create a new ", testEngine.InterpreterResult); | ||
} | ||
|
||
[Test] | ||
public void Engine_NoThis_Method_WorksAsStatic() | ||
{ | ||
testEngine.Run(@" | ||
class T | ||
{ | ||
NoMemberMethod() | ||
{ | ||
retval = 7; | ||
} | ||
} | ||
print(T.NoMemberMethod());"); | ||
|
||
Assert.AreEqual("7", testEngine.InterpreterResult); | ||
} | ||
|
||
[Test] | ||
public void Static_Method_OnClass() | ||
{ | ||
testEngine.Run(@" | ||
class T | ||
{ | ||
static StaticMethod() | ||
{ | ||
retval = 7; | ||
} | ||
} | ||
print(T.StaticMethod());"); | ||
|
||
Assert.AreEqual("7", testEngine.InterpreterResult); | ||
} | ||
|
||
[Test] | ||
public void Static_Method_OnInstance() | ||
{ | ||
testEngine.Run(@" | ||
class T | ||
{ | ||
static StaticMethod() | ||
{ | ||
retval = 7; | ||
} | ||
} | ||
print(T().StaticMethod());" | ||
); | ||
|
||
Assert.AreEqual("7", testEngine.InterpreterResult); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.