Browse Source

Merge pull request #59 from xanathar/remove-antlr

Remove antlr
Marco Mastropaolo 10 years ago
parent
commit
096a256f0a
100 changed files with 4391 additions and 263 deletions
  1. 0 3
      LICENSE
  2. 0 2
      README.md
  3. BIN
      bfg.jar
  4. 0 0
      src/DevTools/MoonSharp.VmDebugger/DoubleBufferedListView.cs
  5. 0 0
      src/DevTools/MoonSharp.VmDebugger/Ext_Methods.cs
  6. 0 0
      src/DevTools/MoonSharp.VmDebugger/MainForm.Designer.cs
  7. 2 4
      src/DevTools/MoonSharp.VmDebugger/MainForm.cs
  8. 0 0
      src/DevTools/MoonSharp.VmDebugger/MainForm.resx
  9. 0 0
      src/DevTools/MoonSharp.VmDebugger/Modules/Test/Builder.lua
  10. 0 0
      src/DevTools/MoonSharp.VmDebugger/Modules/Test/More.lua
  11. 3 3
      src/DevTools/MoonSharp.VmDebugger/MoonSharp.VmDebugger.csproj
  12. 0 0
      src/DevTools/MoonSharp.VmDebugger/Program.cs
  13. 0 0
      src/DevTools/MoonSharp.VmDebugger/Properties/AssemblyInfo.cs
  14. 0 0
      src/DevTools/MoonSharp.VmDebugger/Properties/Resources.Designer.cs
  15. 0 0
      src/DevTools/MoonSharp.VmDebugger/Properties/Resources.resx
  16. 0 0
      src/DevTools/MoonSharp.VmDebugger/Properties/Settings.Designer.cs
  17. 0 0
      src/DevTools/MoonSharp.VmDebugger/Properties/Settings.settings
  18. 0 0
      src/DevTools/MoonSharp.VmDebugger/Resources/AddConnection_477.png
  19. 0 0
      src/DevTools/MoonSharp.VmDebugger/Resources/AddMark_10580.png
  20. 0 0
      src/DevTools/MoonSharp.VmDebugger/Resources/Breakall_6323.png
  21. 0 0
      src/DevTools/MoonSharp.VmDebugger/Resources/BreakpointEnabled_6584_16x.png
  22. 0 0
      src/DevTools/MoonSharp.VmDebugger/Resources/Clearallrequests_8816.png
  23. 0 0
      src/DevTools/MoonSharp.VmDebugger/Resources/DisassemblyWindow_6536.png
  24. 0 0
      src/DevTools/MoonSharp.VmDebugger/Resources/FindSymbol_6263.png
  25. 0 0
      src/DevTools/MoonSharp.VmDebugger/Resources/GoToDeclaration_5576.png
  26. 0 0
      src/DevTools/MoonSharp.VmDebugger/Resources/Help_6522.png
  27. 0 0
      src/DevTools/MoonSharp.VmDebugger/Resources/NavigateBackwards_6270.png
  28. 0 0
      src/DevTools/MoonSharp.VmDebugger/Resources/NavigateForward_6271.png
  29. 0 0
      src/DevTools/MoonSharp.VmDebugger/Resources/Open_6529.png
  30. 0 0
      src/DevTools/MoonSharp.VmDebugger/Resources/RPCThread_10388.png
  31. 0 0
      src/DevTools/MoonSharp.VmDebugger/Resources/Restart_6322.png
  32. 0 0
      src/DevTools/MoonSharp.VmDebugger/Resources/StepIn_6326.png
  33. 0 0
      src/DevTools/MoonSharp.VmDebugger/Resources/StepOver_6328.png
  34. 0 0
      src/DevTools/MoonSharp.VmDebugger/Resources/Stepout_6327.png
  35. 0 0
      src/DevTools/MoonSharp.VmDebugger/Resources/startwithoutdebugging_6556.png
  36. 0 0
      src/DevTools/MoonSharp.VmDebugger/SourceCodeDebugControl.Designer.cs
  37. 0 0
      src/DevTools/MoonSharp.VmDebugger/SourceCodeDebugControl.cs
  38. 0 0
      src/DevTools/MoonSharp.VmDebugger/SourceCodeDebugControl.resx
  39. 0 0
      src/DevTools/MoonSharp.VmDebugger/ValueBrowser.Designer.cs
  40. 0 0
      src/DevTools/MoonSharp.VmDebugger/ValueBrowser.cs
  41. 0 0
      src/DevTools/MoonSharp.VmDebugger/ValueBrowser.resx
  42. 0 0
      src/DevTools/MoonSharp.VmDebugger/WatchInputDialog.Designer.cs
  43. 0 0
      src/DevTools/MoonSharp.VmDebugger/WatchInputDialog.cs
  44. 0 0
      src/DevTools/MoonSharp.VmDebugger/WatchInputDialog.resx
  45. 0 0
      src/DevTools/PerformanceComparison/CallbacksAndForthTests.cs
  46. 0 0
      src/DevTools/PerformanceComparison/CoroutineTest.cs
  47. 5 5
      src/DevTools/PerformanceComparison/HugeFile.cs
  48. 3 6
      src/DevTools/PerformanceComparison/PerformanceComparison.csproj
  49. 3 1
      src/DevTools/PerformanceComparison/Program.cs
  50. 0 0
      src/DevTools/PerformanceComparison/Properties/AssemblyInfo.cs
  51. 0 0
      src/DevTools/PerformanceComparison/Sample.cs
  52. 0 0
      src/DevTools/PerformanceComparison/app.config
  53. 152 0
      src/DevTools/SynchProjects/Program.cs
  54. 36 0
      src/DevTools/SynchProjects/Properties/AssemblyInfo.cs
  55. 55 0
      src/DevTools/SynchProjects/SynchProjects.csproj
  56. 76 0
      src/MoonSharp.Interpreter.Tests/EmbeddableNUnitWrapper.cs
  57. 101 0
      src/MoonSharp.Interpreter.Tests/EndToEnd/ErrorHandlingTests.cs
  58. 220 0
      src/MoonSharp.Interpreter.Tests/EndToEnd/GotoTests.cs
  59. 167 17
      src/MoonSharp.Interpreter.Tests/EndToEnd/SimpleTests.cs
  60. 1 1
      src/MoonSharp.Interpreter.Tests/EndToEnd/TableTests.cs
  61. 10 0
      src/MoonSharp.Interpreter.Tests/EndToEnd/UserDataMethodsTests.cs
  62. 11 1
      src/MoonSharp.Interpreter.Tests/EndToEnd/UserDataPropertiesTests.cs
  63. 0 116
      src/MoonSharp.Interpreter.Tests/ErrorHandlingTests.cs
  64. 9 7
      src/MoonSharp.Interpreter.Tests/MoonSharp.Interpreter.Tests.net35-client.csproj
  65. 2 2
      src/MoonSharp.Interpreter.Tests/Properties/AssemblyInfo.cs
  66. 27 9
      src/MoonSharp.Interpreter.Tests/TapRunner.cs
  67. 14 22
      src/MoonSharp.Interpreter.Tests/TestMore/203-lexico.t
  68. 2 2
      src/MoonSharp.Interpreter.Tests/TestMore/214-coroutine.t
  69. 5 1
      src/MoonSharp.Interpreter.Tests/TestMore/304-string.t
  70. 7 2
      src/MoonSharp.Interpreter.Tests/TestMore/305-table.t
  71. 59 55
      src/MoonSharp.Interpreter.Tests/TestMoreTests.cs
  72. 20 4
      src/MoonSharp.Interpreter.Tests/TestRunner.cs
  73. 173 0
      src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/MoonSharp.Interpreter.Tests.Embeddable.portable40.csproj
  74. 30 0
      src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/Properties/AssemblyInfo.cs
  75. 54 0
      src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/000-sanity.t
  76. 87 0
      src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/001-if.t
  77. 67 0
      src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/002-table.t
  78. 80 0
      src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/011-while.t
  79. 78 0
      src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/012-repeat.t
  80. 136 0
      src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/014-fornum.t
  81. 99 0
      src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/015-forlist.t
  82. 120 0
      src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/101-boolean.t
  83. 199 0
      src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/102-function.t
  84. 120 0
      src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/103-nil.t
  85. 190 0
      src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/104-number.t
  86. 183 0
      src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/105-string.t
  87. 125 0
      src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/106-table.t
  88. 128 0
      src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/107-thread.t
  89. 125 0
      src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/108-userdata.t
  90. 104 0
      src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/200-examples.t
  91. 125 0
      src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/201-assign.t
  92. 111 0
      src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/202-expr.t
  93. 122 0
      src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/203-lexico.t
  94. 106 0
      src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/204-grammar.t
  95. 83 0
      src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/211-scope.t
  96. 268 0
      src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/212-function.t
  97. 98 0
      src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/213-closure.t
  98. 193 0
      src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/214-coroutine.t
  99. 112 0
      src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/221-table.t
  100. 85 0
      src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/222-constructor.t

+ 0 - 3
LICENSE

@@ -1,9 +1,6 @@
 Copyright (c) 2014, Marco Mastropaolo
 Copyright (c) 2014, Marco Mastropaolo
 All rights reserved.
 All rights reserved.
 
 
-This work is based on the ANTLR4 Lua grammar 
-Copyright (c) 2013, Kazunori Sakamoto
-
 Parts of the string library are based on the KopiLua project (https://github.com/NLua/KopiLua)
 Parts of the string library are based on the KopiLua project (https://github.com/NLua/KopiLua)
 Copyright (c) 2012 LoDC
 Copyright (c) 2012 LoDC
 
 

+ 0 - 2
README.md

@@ -15,8 +15,6 @@ Please see http://www.moonsharp.org for downloads, infos, tutorials, etc.
 
 
 The program and libraries are released under a 3-clause BSD license - see the license section.
 The program and libraries are released under a 3-clause BSD license - see the license section.
 
 
-This work is based on the ANTLR4 Lua grammar Copyright (c) 2013, Kazunori Sakamoto.
-
 Parts of the string library are based on the KopiLua project (https://github.com/NLua/KopiLua).
 Parts of the string library are based on the KopiLua project (https://github.com/NLua/KopiLua).
 
 
 Debugger icons are from the Eclipse project (https://www.eclipse.org/).
 Debugger icons are from the Eclipse project (https://www.eclipse.org/).

BIN
src/Unity/UnityTestBed/_outputs/android/tests.apk → bfg.jar


+ 0 - 0
src/MoonSharp.Debugger/DoubleBufferedListView.cs → src/DevTools/MoonSharp.VmDebugger/DoubleBufferedListView.cs


+ 0 - 0
src/MoonSharp.Debugger/Ext_Methods.cs → src/DevTools/MoonSharp.VmDebugger/Ext_Methods.cs


+ 0 - 0
src/MoonSharp.Debugger/MainForm.Designer.cs → src/DevTools/MoonSharp.VmDebugger/MainForm.Designer.cs


+ 2 - 4
src/MoonSharp.Debugger/MainForm.cs → src/DevTools/MoonSharp.VmDebugger/MainForm.cs

@@ -66,13 +66,11 @@ namespace MoonSharp.Debugger
 
 
 		private void DebugScript(string filename)
 		private void DebugScript(string filename)
 		{
 		{
-			m_Script = new Script(CoreModules.Basic);
+			m_Script = new Script(CoreModules.Preset_Complete);
 			m_Script.Options.UseLuaErrorLocations = true;
 			m_Script.Options.UseLuaErrorLocations = true;
 			m_Script.Options.DebugPrint = s => { Console_WriteLine("{0}", s); };
 			m_Script.Options.DebugPrint = s => { Console_WriteLine("{0}", s); };
 
 
-			var L = new ClassicLuaScriptLoader();
-			L.ModulePaths = L.UnpackStringPaths("Modules/?;Modules/?.lua");
-			m_Script.Options.ScriptLoader = L;
+			((ScriptLoaderBase)m_Script.Options.ScriptLoader).ModulePaths = ScriptLoaderBase.UnpackStringPaths("Modules/?;Modules/?.lua");
 
 
 			try
 			try
 			{
 			{

+ 0 - 0
src/MoonSharp.Debugger/MainForm.resx → src/DevTools/MoonSharp.VmDebugger/MainForm.resx


+ 0 - 0
src/MoonSharp.Debugger/Modules/Test/Builder.lua → src/DevTools/MoonSharp.VmDebugger/Modules/Test/Builder.lua


+ 0 - 0
src/MoonSharp.Debugger/Modules/Test/More.lua → src/DevTools/MoonSharp.VmDebugger/Modules/Test/More.lua


+ 3 - 3
src/MoonSharp.Debugger/MoonSharp.Debugger.csproj → src/DevTools/MoonSharp.VmDebugger/MoonSharp.VmDebugger.csproj

@@ -8,7 +8,7 @@
     <OutputType>WinExe</OutputType>
     <OutputType>WinExe</OutputType>
     <AppDesignerFolder>Properties</AppDesignerFolder>
     <AppDesignerFolder>Properties</AppDesignerFolder>
     <RootNamespace>MoonSharp.Debugger</RootNamespace>
     <RootNamespace>MoonSharp.Debugger</RootNamespace>
-    <AssemblyName>MoonSharp.Debugger</AssemblyName>
+    <AssemblyName>MoonSharp.VmDebugger</AssemblyName>
     <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
     <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
     <FileAlignment>512</FileAlignment>
   </PropertyGroup>
   </PropertyGroup>
@@ -130,9 +130,9 @@
     </None>
     </None>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
-    <ProjectReference Include="..\MoonSharp.Interpreter\MoonSharp.Interpreter.csproj">
+    <ProjectReference Include="..\..\MoonSharp.Interpreter\MoonSharp.Interpreter.net35-client.csproj">
       <Project>{91ea9b9d-fe03-4273-bdaf-8ad42ede1e59}</Project>
       <Project>{91ea9b9d-fe03-4273-bdaf-8ad42ede1e59}</Project>
-      <Name>MoonSharp.Interpreter</Name>
+      <Name>MoonSharp.Interpreter.net35-client</Name>
     </ProjectReference>
     </ProjectReference>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>

+ 0 - 0
src/MoonSharp.Debugger/Program.cs → src/DevTools/MoonSharp.VmDebugger/Program.cs


+ 0 - 0
src/MoonSharp.Debugger/Properties/AssemblyInfo.cs → src/DevTools/MoonSharp.VmDebugger/Properties/AssemblyInfo.cs


+ 0 - 0
src/MoonSharp.Debugger/Properties/Resources.Designer.cs → src/DevTools/MoonSharp.VmDebugger/Properties/Resources.Designer.cs


+ 0 - 0
src/MoonSharp.Debugger/Properties/Resources.resx → src/DevTools/MoonSharp.VmDebugger/Properties/Resources.resx


+ 0 - 0
src/MoonSharp.Debugger/Properties/Settings.Designer.cs → src/DevTools/MoonSharp.VmDebugger/Properties/Settings.Designer.cs


+ 0 - 0
src/MoonSharp.Debugger/Properties/Settings.settings → src/DevTools/MoonSharp.VmDebugger/Properties/Settings.settings


+ 0 - 0
src/MoonSharp.Debugger/Resources/AddConnection_477.png → src/DevTools/MoonSharp.VmDebugger/Resources/AddConnection_477.png


+ 0 - 0
src/MoonSharp.Debugger/Resources/AddMark_10580.png → src/DevTools/MoonSharp.VmDebugger/Resources/AddMark_10580.png


+ 0 - 0
src/MoonSharp.Debugger/Resources/Breakall_6323.png → src/DevTools/MoonSharp.VmDebugger/Resources/Breakall_6323.png


+ 0 - 0
src/MoonSharp.Debugger/Resources/BreakpointEnabled_6584_16x.png → src/DevTools/MoonSharp.VmDebugger/Resources/BreakpointEnabled_6584_16x.png


+ 0 - 0
src/MoonSharp.Debugger/Resources/Clearallrequests_8816.png → src/DevTools/MoonSharp.VmDebugger/Resources/Clearallrequests_8816.png


+ 0 - 0
src/MoonSharp.Debugger/Resources/DisassemblyWindow_6536.png → src/DevTools/MoonSharp.VmDebugger/Resources/DisassemblyWindow_6536.png


+ 0 - 0
src/MoonSharp.Debugger/Resources/FindSymbol_6263.png → src/DevTools/MoonSharp.VmDebugger/Resources/FindSymbol_6263.png


+ 0 - 0
src/MoonSharp.Debugger/Resources/GoToDeclaration_5576.png → src/DevTools/MoonSharp.VmDebugger/Resources/GoToDeclaration_5576.png


+ 0 - 0
src/MoonSharp.Debugger/Resources/Help_6522.png → src/DevTools/MoonSharp.VmDebugger/Resources/Help_6522.png


+ 0 - 0
src/MoonSharp.Debugger/Resources/NavigateBackwards_6270.png → src/DevTools/MoonSharp.VmDebugger/Resources/NavigateBackwards_6270.png


+ 0 - 0
src/MoonSharp.Debugger/Resources/NavigateForward_6271.png → src/DevTools/MoonSharp.VmDebugger/Resources/NavigateForward_6271.png


+ 0 - 0
src/MoonSharp.Debugger/Resources/Open_6529.png → src/DevTools/MoonSharp.VmDebugger/Resources/Open_6529.png


+ 0 - 0
src/MoonSharp.Debugger/Resources/RPCThread_10388.png → src/DevTools/MoonSharp.VmDebugger/Resources/RPCThread_10388.png


+ 0 - 0
src/MoonSharp.Debugger/Resources/Restart_6322.png → src/DevTools/MoonSharp.VmDebugger/Resources/Restart_6322.png


+ 0 - 0
src/MoonSharp.Debugger/Resources/StepIn_6326.png → src/DevTools/MoonSharp.VmDebugger/Resources/StepIn_6326.png


+ 0 - 0
src/MoonSharp.Debugger/Resources/StepOver_6328.png → src/DevTools/MoonSharp.VmDebugger/Resources/StepOver_6328.png


+ 0 - 0
src/MoonSharp.Debugger/Resources/Stepout_6327.png → src/DevTools/MoonSharp.VmDebugger/Resources/Stepout_6327.png


+ 0 - 0
src/MoonSharp.Debugger/Resources/startwithoutdebugging_6556.png → src/DevTools/MoonSharp.VmDebugger/Resources/startwithoutdebugging_6556.png


+ 0 - 0
src/MoonSharp.Debugger/SourceCodeDebugControl.Designer.cs → src/DevTools/MoonSharp.VmDebugger/SourceCodeDebugControl.Designer.cs


+ 0 - 0
src/MoonSharp.Debugger/SourceCodeDebugControl.cs → src/DevTools/MoonSharp.VmDebugger/SourceCodeDebugControl.cs


+ 0 - 0
src/MoonSharp.Debugger/SourceCodeDebugControl.resx → src/DevTools/MoonSharp.VmDebugger/SourceCodeDebugControl.resx


+ 0 - 0
src/MoonSharp.Debugger/ValueBrowser.Designer.cs → src/DevTools/MoonSharp.VmDebugger/ValueBrowser.Designer.cs


+ 0 - 0
src/MoonSharp.Debugger/ValueBrowser.cs → src/DevTools/MoonSharp.VmDebugger/ValueBrowser.cs


+ 0 - 0
src/MoonSharp.Debugger/ValueBrowser.resx → src/DevTools/MoonSharp.VmDebugger/ValueBrowser.resx


+ 0 - 0
src/MoonSharp.Debugger/WatchInputDialog.Designer.cs → src/DevTools/MoonSharp.VmDebugger/WatchInputDialog.Designer.cs


+ 0 - 0
src/MoonSharp.Debugger/WatchInputDialog.cs → src/DevTools/MoonSharp.VmDebugger/WatchInputDialog.cs


+ 0 - 0
src/MoonSharp.Debugger/WatchInputDialog.resx → src/DevTools/MoonSharp.VmDebugger/WatchInputDialog.resx


+ 0 - 0
src/PerformanceComparison/CallbacksAndForthTests.cs → src/DevTools/PerformanceComparison/CallbacksAndForthTests.cs


+ 0 - 0
src/PerformanceComparison/CoroutineTest.cs → src/DevTools/PerformanceComparison/CoroutineTest.cs


+ 5 - 5
src/PerformanceComparison/HugeFile.cs → src/DevTools/PerformanceComparison/HugeFile.cs

@@ -4,13 +4,13 @@ using System.Diagnostics;
 using System.Linq;
 using System.Linq;
 using System.Text;
 using System.Text;
 using MoonSharp.Interpreter;
 using MoonSharp.Interpreter;
-using MoonSharp.Interpreter.Grammar;
+
 
 
 namespace PerformanceComparison
 namespace PerformanceComparison
 {
 {
 	public class HugeFile
 	public class HugeFile
 	{
 	{
-		static void xxxxMain(string[] args)
+		static void xxMain(string[] args)
 		{
 		{
 			Console.WriteLine("Started...");
 			Console.WriteLine("Started...");
 			Script.WarmUp();
 			Script.WarmUp();
@@ -23,10 +23,10 @@ namespace PerformanceComparison
 			Stopwatch sw = Stopwatch.StartNew();
 			Stopwatch sw = Stopwatch.StartNew();
 
 
 			//for (int i = 0; i < 10; i++)
 			//for (int i = 0; i < 10; i++)
-			var v = s.LoadFile(@"C:\temp\test3.lua");
+				var v = s.LoadFile(@"C:\temp\test3.lua");
 
 
-			for(int i = 0; i < 1000; i++)
-				s.Call(v);
+			//for(int i = 0; i < 1000; i++)
+			//	s.Call(v);
 
 
 			sw.Stop();
 			sw.Stop();
 
 

+ 3 - 6
src/PerformanceComparison/PerformanceComparison.csproj → src/DevTools/PerformanceComparison/PerformanceComparison.csproj

@@ -66,11 +66,8 @@
     <Prefer32Bit>false</Prefer32Bit>
     <Prefer32Bit>false</Prefer32Bit>
   </PropertyGroup>
   </PropertyGroup>
   <ItemGroup>
   <ItemGroup>
-    <Reference Include="KeraLua">
-      <HintPath>..\..\..\..\prg\NLua\KeraLua.dll</HintPath>
-    </Reference>
     <Reference Include="NLua">
     <Reference Include="NLua">
-      <HintPath>..\..\..\..\prg\NLua\NLua.dll</HintPath>
+      <HintPath>..\..\..\..\..\prg\NLua\NLua.dll</HintPath>
     </Reference>
     </Reference>
     <Reference Include="System" />
     <Reference Include="System" />
     <Reference Include="System.Core" />
     <Reference Include="System.Core" />
@@ -90,9 +87,9 @@
     <Compile Include="Sample.cs" />
     <Compile Include="Sample.cs" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
-    <ProjectReference Include="..\MoonSharp.Interpreter\MoonSharp.Interpreter.csproj">
+    <ProjectReference Include="..\..\MoonSharp.Interpreter\MoonSharp.Interpreter.net35-client.csproj">
       <Project>{91ea9b9d-fe03-4273-bdaf-8ad42ede1e59}</Project>
       <Project>{91ea9b9d-fe03-4273-bdaf-8ad42ede1e59}</Project>
-      <Name>MoonSharp.Interpreter</Name>
+      <Name>MoonSharp.Interpreter.net35-client</Name>
     </ProjectReference>
     </ProjectReference>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>

+ 3 - 1
src/PerformanceComparison/Program.cs → src/DevTools/PerformanceComparison/Program.cs

@@ -30,7 +30,7 @@ namespace PerformanceComparison
 			function move(n, src, dst, via)
 			function move(n, src, dst, via)
 				if n > 0 then
 				if n > 0 then
 					move(n - 1, src, via, dst)
 					move(n - 1, src, via, dst)
-					check(src, 'to', dst)
+					--check(src, 'to', dst)
 					move(n - 1, via, dst, src)
 					move(n - 1, via, dst, src)
 				end
 				end
 			end
 			end
@@ -125,6 +125,8 @@ end
 
 
 		static void Main(string[] args)
 		static void Main(string[] args)
 		{
 		{
+			Script.WarmUp();
+
 			Stopwatch sw;
 			Stopwatch sw;
 
 
 			sw = Stopwatch.StartNew();
 			sw = Stopwatch.StartNew();

+ 0 - 0
src/PerformanceComparison/Properties/AssemblyInfo.cs → src/DevTools/PerformanceComparison/Properties/AssemblyInfo.cs


+ 0 - 0
src/PerformanceComparison/Sample.cs → src/DevTools/PerformanceComparison/Sample.cs


+ 0 - 0
src/PerformanceComparison/app.config → src/DevTools/PerformanceComparison/app.config


+ 152 - 0
src/DevTools/SynchProjects/Program.cs

@@ -0,0 +1,152 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Xml;
+
+namespace SynchProjects
+{
+	class Program
+	{
+		static string BASEPATH;
+
+		static void CopyCompileFilesAsLinks(string platformName, string srcCsProj, string platformDest, string pathPrefix)
+		{
+			platformName = AdjustBasePath(platformName);
+			srcCsProj = AdjustBasePath(srcCsProj);
+			platformDest = AdjustBasePath(platformDest);
+			pathPrefix = AdjustBasePath(pathPrefix);
+
+			string dstCsProj = string.Format(platformDest, platformName);
+			try
+			{
+				int warningCount = 0;
+				const string XMLNS = "http://schemas.microsoft.com/developer/msbuild/2003";
+				HashSet<string> linksDone = new HashSet<string>();
+
+				Console.ForegroundColor = ConsoleColor.Gray;
+				Console.WriteLine("Synch vsproj compiles {0} ...", Path.GetFileNameWithoutExtension(dstCsProj));
+
+				XmlDocument xsrc = new XmlDocument();
+				XmlDocument xdst = new XmlDocument();
+
+				xsrc.Load(srcCsProj);
+				xdst.Load(dstCsProj);
+
+				XmlNamespaceManager sxns = new XmlNamespaceManager(xsrc.NameTable);
+				XmlNamespaceManager dxns = new XmlNamespaceManager(xdst.NameTable);
+
+				sxns.AddNamespace("ms", XMLNS);
+				dxns.AddNamespace("ms", XMLNS);
+
+				XmlElement srccont = xsrc.SelectSingleNode("/ms:Project/ms:ItemGroup[count(ms:Compile) != 0]", sxns) as XmlElement;
+				XmlElement dstcont = xdst.SelectSingleNode("/ms:Project/ms:ItemGroup[count(ms:Compile) != 0]", dxns) as XmlElement;
+
+				// dirty hack
+				dstcont.InnerXml = srccont.InnerXml;
+
+				List<XmlElement> toRemove = new List<XmlElement>();
+
+				foreach (XmlElement xe in dstcont.ChildNodes.OfType<XmlElement>())
+				{
+					string file = xe.GetAttribute("Include");
+					string link = Path.GetFileName(file);
+
+					if (link.Contains(".g4"))
+					{
+						toRemove.Add(xe);
+						continue;
+					}
+
+					if (!linksDone.Add(link))
+					{
+						++warningCount;
+						Console.ForegroundColor = ConsoleColor.Yellow;
+						Console.WriteLine("\t[WARNING] - Duplicate file: {0}", link);
+					}
+
+					file = pathPrefix + file;
+
+					xe.SetAttribute("Include", file);
+
+					XmlElement xlink = xe.OwnerDocument.CreateElement("Link", XMLNS);
+					xlink.InnerText = link;
+					xe.AppendChild(xlink);
+				}
+
+				foreach (XmlElement xe in toRemove)
+					xe.ParentNode.RemoveChild(xe);
+
+				xdst.Save(dstCsProj);
+				Console.ForegroundColor = ConsoleColor.Green;
+				Console.WriteLine("\t[DONE] ({0} warnings)", warningCount);
+			}
+			catch (Exception ex)
+			{
+				Console.ForegroundColor = ConsoleColor.Red;
+				Console.WriteLine("\t[ERROR] - {0}", ex.Message);
+			}
+
+			Console.WriteLine("\n");
+		}
+
+		private static string AdjustBasePath(string str)
+		{
+			return str.Replace("{BASEPATH}", BASEPATH);
+		}
+
+		static void Main(string[] args)
+		{
+			const string INTERPRETER_PROJECT = @"{BASEPATH}\MoonSharp.Interpreter\MoonSharp.Interpreter.net35-client.csproj";
+			const string INTERPRETER_SUBPROJECTS_PATHS = @"{BASEPATH}\MoonSharp.Interpreter\_Projects\MoonSharp.Interpreter.{0}\MoonSharp.Interpreter.{0}.csproj";
+			const string INTERPRETER_PATH_PREFIX = @"..\..\";
+
+			const string DEBUGGER_PROJECT = @"{BASEPATH}\MoonSharp.RemoteDebugger\MoonSharp.RemoteDebugger.net35-client.csproj";
+			const string DEBUGGER_SUBPROJECTS_PATHS = @"{BASEPATH}\MoonSharp.RemoteDebugger\_Projects\MoonSharp.RemoteDebugger.{0}\MoonSharp.RemoteDebugger.{0}.csproj";
+			const string DEBUGGER_PATH_PREFIX = @"..\..\";
+
+			const string TESTS_PROJECT = @"{BASEPATH}\MoonSharp.Interpreter.Tests\MoonSharp.Interpreter.Tests.net35-client.csproj";
+			const string TESTS_SUBPROJECTS_PATHS = @"{BASEPATH}\MoonSharp.Interpreter.Tests\_Projects\MoonSharp.Interpreter.Tests.{0}\MoonSharp.Interpreter.Tests.{0}.csproj";
+			const string TESTS_PATH_PREFIX = @"..\..\";
+
+			string[] INTERPRETER_PLATFORMS = new string[] { "net40-client", "portable40" };
+			string[] DEBUGGER_PLATFORMS = new string[] { "net40-client" };
+			string[] TESTS_PLATFORMS = new string[] { "net40-client", "portable40", "Embeddable.portable40" };
+
+			CalcBasePath();
+
+			foreach (string platform in INTERPRETER_PLATFORMS)
+				CopyCompileFilesAsLinks(platform, INTERPRETER_PROJECT, INTERPRETER_SUBPROJECTS_PATHS, INTERPRETER_PATH_PREFIX);
+
+			foreach (string platform in DEBUGGER_PLATFORMS)
+				CopyCompileFilesAsLinks(platform, DEBUGGER_PROJECT, DEBUGGER_SUBPROJECTS_PATHS, DEBUGGER_PATH_PREFIX);
+
+			foreach (string platform in TESTS_PLATFORMS)
+				CopyCompileFilesAsLinks(platform, TESTS_PROJECT, TESTS_SUBPROJECTS_PATHS, TESTS_PATH_PREFIX);
+
+
+			Console.ReadLine();
+		}
+
+		private static void CalcBasePath()
+		{
+			string path = "";
+			string[] dir = AppDomain.CurrentDomain.BaseDirectory.Split('\\');
+
+			for (int i = 0; i < dir.Length; i++)
+			{
+				if (dir[i].ToLower() == "devtools")
+					break;
+
+				if (path.Length > 0)
+					path = path + "\\" + dir[i];
+				else
+					path = dir[i];
+			}
+
+			BASEPATH = path;
+		}
+	}
+}

+ 36 - 0
src/DevTools/SynchProjects/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("SynchProjects")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("SynchProjects")]
+[assembly: AssemblyCopyright("Copyright ©  2014")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("a4934800-dd77-4047-b402-4eec63bbcf2f")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 55 - 0
src/DevTools/SynchProjects/SynchProjects.csproj

@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{321C9CCF-6F9B-4751-AB34-882DEE982A7E}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>SynchProjects</RootNamespace>
+    <AssemblyName>SynchProjects</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 76 - 0
src/MoonSharp.Interpreter.Tests/EmbeddableNUnitWrapper.cs

@@ -0,0 +1,76 @@
+#if EMBEDTEST
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace NUnit.Framework
+{
+	public class TestAttribute : Attribute
+	{ }
+
+	public class IgnoreAttribute : Attribute
+	{ }
+
+	public class TestFixtureAttribute : Attribute
+	{ }
+
+	public class ExpectedExceptionAttribute : Attribute
+	{
+		public Type ExpectedException { get; set; }
+
+		public ExpectedExceptionAttribute(Type t)
+		{
+			ExpectedException = t;
+		}
+	}
+
+	public static class Assert
+	{
+		public static void AreEqual(int expected, double other, string message = null)
+		{
+			Assert.IsTrue((double)expected == other, message ?? string.Format("{0} was expected, {1} was returned", expected, other));
+		}
+
+		public static void AreEqual(object expected, object other, string message = null)
+		{
+			if (expected != null)
+				Assert.IsTrue(expected.Equals(other), message ?? string.Format("{0} was expected, {1} was returned", expected, other));
+			else
+				Assert.IsTrue(other == null, message ?? string.Format("null was expected, {0} was returned", other));
+		}
+
+		public static void IsTrue(bool condition, string message)
+		{
+			if (!condition)
+				throw new Exception("Test failed : " + message);
+		}
+
+		public static void IsFalse(bool condition, string message)
+		{
+			IsTrue(!condition, message);
+		}
+
+		internal static void IsNotNull(object o)
+		{
+			IsFalse(o == null, "Object is null");
+		}
+
+		internal static void IsNotNullOrEmpty(string p)
+		{
+			IsFalse(string.IsNullOrEmpty(p), "String is null or empty");
+		}
+
+		internal static void IsTrue(bool p)
+		{
+			IsTrue(p, "Value not true");
+		}
+	}
+
+
+
+}
+
+
+#endif

+ 101 - 0
src/MoonSharp.Interpreter.Tests/EndToEnd/ErrorHandlingTests.cs

@@ -25,6 +25,107 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 			Assert.AreEqual(3, res.Tuple[3].Number);
 			Assert.AreEqual(3, res.Tuple[3].Number);
 		}
 		}
 
 
+		[Test]
+		public void Errors_PCall_ClrFunction()
+		{
+			string script = @"
+				r, msg = pcall(assert, false, 'catched')
+				return r, msg;
+								";
+
+			DynValue res = Script.RunString(script);
+
+			Assert.AreEqual(DataType.Tuple, res.Type);
+			Assert.AreEqual(2, res.Tuple.Length);
+			Assert.AreEqual(DataType.Boolean, res.Tuple[0].Type);
+			Assert.AreEqual(DataType.String, res.Tuple[1].Type);
+			Assert.AreEqual(false, res.Tuple[0].Boolean);
+		}
+
+		[Test]
+		public void Errors_PCall_Multiples()
+		{
+			string script = @"
+function try(fn)
+	local x, y = pcall(fn)
+	
+	if (x) then
+		return y
+	else
+		return '!'
+	end
+end
+
+function a()
+	return try(b) .. 'a';
+end
+
+function b()
+	return try(c) .. 'b';
+end
+
+function c()
+	return try(d) .. 'c';
+end
+
+function d()
+	local t = { } .. 'x'
+end
+
+
+return a()
+";
+
+			DynValue res = Script.RunString(script);
+
+			Assert.AreEqual(DataType.String, res.Type);
+			Assert.AreEqual("!cba", res.String);
+		}
+
+		[Test]
+		public void Errors_TryCatch_Multiples()
+		{
+			string script = @"
+function a()
+	return try(b) .. 'a';
+end
+
+function b()
+	return try(c) .. 'b';
+end
+
+function c()
+	return try(d) .. 'c';
+end
+
+function d()
+	local t = { } .. 'x'
+end
+
+
+return a()
+";
+			Script S = new Script(CoreModules.None);
+
+			S.Globals["try"] = DynValue.NewCallback((c, a) =>
+			{
+				try
+				{
+					var v = a[0].Function.Call();
+					return v;
+				}
+				catch (ScriptRuntimeException)
+				{
+					return DynValue.NewString("!");
+				}
+			});
+
+
+			DynValue res = S.DoString(script);
+
+			Assert.AreEqual(DataType.String, res.Type);
+			Assert.AreEqual("!cba", res.String);
+		}
 
 
 	}
 	}
 }
 }

+ 220 - 0
src/MoonSharp.Interpreter.Tests/EndToEnd/GotoTests.cs

@@ -0,0 +1,220 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using NUnit.Framework;
+
+namespace MoonSharp.Interpreter.Tests.EndToEnd
+{
+	[TestFixture]
+	public class GotoTests
+	{
+		[Test]
+		public void Goto_Simple_Fwd()
+		{
+			string script = @"
+				function test()
+					x = 3
+					goto skip	
+					x = x + 2;
+					::skip::
+					return x;
+				end				
+
+				return test();
+				";
+
+			DynValue res = Script.RunString(script);
+
+			Assert.AreEqual(DataType.Number, res.Type);
+			Assert.AreEqual(3, res.Number);
+		}
+
+		[Test]
+		public void Goto_Simple_Bwd()
+		{
+			string script = @"
+				function test()
+					x = 5;
+	
+					::jump::
+					if (x == 3) then return x; end
+					
+					x = 3
+					goto jump
+
+					x = 4
+					return x;
+				end				
+
+				return test();
+				";
+
+			DynValue res = Script.RunString(script);
+
+			Assert.AreEqual(DataType.Number, res.Type);
+			Assert.AreEqual(3, res.Number);
+		}
+
+		[Test]
+		[ExpectedException(typeof(SyntaxErrorException))]
+		public void Goto_UndefinedLabel()
+		{
+			string script = @"
+				goto there
+				";
+
+			Script.RunString(script);
+		}
+
+		[Test]
+		[ExpectedException(typeof(SyntaxErrorException))]
+		public void Goto_DoubleDefinedLabel()
+		{
+			string script = @"
+				::label::
+				::label::
+				";
+
+			Script.RunString(script);
+		}
+
+		[Test]
+		public void Goto_RedefinedLabel()
+		{
+			string script = @"
+				::label::
+				do
+					::label::
+				end
+				";
+
+			Script.RunString(script);
+		}
+
+		[Test]
+		public void Goto_RedefinedLabel_Goto()
+		{
+			string script = @"
+				::label::
+				do
+					goto label
+					do return 5 end
+					::label::
+					return 3
+				end
+				";
+
+			DynValue res = Script.RunString(script);
+
+			Assert.AreEqual(DataType.Number, res.Type);
+			Assert.AreEqual(3, res.Number);
+		}
+
+		[Test]
+		[ExpectedException(typeof(SyntaxErrorException))]
+		public void Goto_UndefinedLabel_2()
+		{
+			string script = @"
+				goto label
+				do
+					do return 5 end
+					::label::
+					return 3
+				end
+				";
+
+			DynValue res = Script.RunString(script);
+
+			Assert.AreEqual(DataType.Number, res.Type);
+			Assert.AreEqual(3, res.Number);
+		}
+
+		[Test]
+		[ExpectedException(typeof(SyntaxErrorException))]
+		public void Goto_VarInScope()
+		{
+			string script = @"
+				goto f
+				local x
+				::f::
+				";
+
+			DynValue res = Script.RunString(script);
+
+			Assert.AreEqual(DataType.Number, res.Type);
+			Assert.AreEqual(3, res.Number);
+		}
+
+
+		[Test]
+		public void Goto_JumpOutOfBlocks()
+		{
+			string script = @"
+				local u = 4
+
+				do
+					local x = 5
+	
+					do
+						local y = 6
+		
+						do
+							local z = 7
+						end
+		
+						goto out
+					end
+				end
+
+				do return 5 end
+
+				::out::
+
+				return 3
+			";
+
+			DynValue res = Script.RunString(script);
+			Assert.AreEqual(DataType.Number, res.Type);
+			Assert.AreEqual(3, res.Number);
+		}
+
+		[Test]
+		public void Goto_JumpOutOfScopes()
+		{
+			string script = @"
+				local u = 4
+
+				do
+					local x = 5
+					do
+						local y = 6
+						do
+							goto out
+							local z = 7
+						end
+		
+					end
+				end
+
+				::out::
+
+				do 
+					local a
+					local b = 55
+
+					if (a == nil) then
+						b = b + 12
+					end
+
+					return b
+				end
+
+			";
+
+			DynValue res = Script.RunString(script);
+			Assert.AreEqual(DataType.Number, res.Type);
+			Assert.AreEqual(67, res.Number);
+		}
+	}
+}

+ 167 - 17
src/MoonSharp.Interpreter.Tests/EndToEnd/SimpleTests.cs

@@ -9,6 +9,12 @@ namespace MoonSharp.Interpreter.Tests
 	[TestFixture]
 	[TestFixture]
 	public class SimpleTests
 	public class SimpleTests
 	{
 	{
+		[Test]
+		public void EmptyChunk()
+		{
+			Script S = new Script(CoreModules.None);
+			DynValue res = S.DoString("");
+		}
 
 
 		[Test]
 		[Test]
 		public void CSharpStaticFunctionCallStatement()
 		public void CSharpStaticFunctionCallStatement()
@@ -55,6 +61,58 @@ namespace MoonSharp.Interpreter.Tests
 			Assert.AreEqual(DataType.Void, res.Type);
 			Assert.AreEqual(DataType.Void, res.Type);
 		}
 		}
 
 
+		[Test]
+		public void CSharpStaticFunctionCall4()
+		{
+			string script = "return callback()();";
+
+			var callback2 = DynValue.NewCallback(new CallbackFunction((_x, a) => { return DynValue.NewNumber(1234.0); }));
+			var callback = DynValue.NewCallback(new CallbackFunction((_x, a) => { return callback2; }));
+
+			var S = new Script();
+			S.Globals.Set("callback", callback);
+
+			DynValue res = S.DoString(script);
+
+			Assert.AreEqual(DataType.Number, res.Type);
+			Assert.AreEqual(1234.0, res.Number);
+		}
+
+		[Test]
+		public void CSharpStaticFunctionCall3()
+		{
+			string script = "return callback();";
+
+			var callback = DynValue.NewCallback(new CallbackFunction((_x, a) => { return DynValue.NewNumber(1234.0); }));
+
+			var S = new Script();
+			S.Globals.Set("callback", callback);
+
+			DynValue res = S.DoString(script);
+
+			Assert.AreEqual(DataType.Number, res.Type);
+			Assert.AreEqual(1234.0, res.Number);
+		}
+
+		[Test]
+		public void CSharpStaticFunctionCall2()
+		{
+			IList<DynValue> args = null;
+
+			string script = "return callback 'hello';";
+
+			var S = new Script();
+			S.Globals.Set("callback", DynValue.NewCallback(new CallbackFunction((_x, a) => { args = a.GetArray(); return DynValue.NewNumber(1234.0); })));
+
+			DynValue res = S.DoString(script);
+
+			Assert.AreEqual(1, args.Count);
+			Assert.AreEqual(DataType.String, args[0].Type);
+			Assert.AreEqual("hello", args[0].String);
+			Assert.AreEqual(DataType.Number, res.Type);
+			Assert.AreEqual(1234.0, res.Number);
+		}
+
 		[Test]
 		[Test]
 		public void CSharpStaticFunctionCall()
 		public void CSharpStaticFunctionCall()
 		{
 		{
@@ -77,6 +135,7 @@ namespace MoonSharp.Interpreter.Tests
 		}
 		}
 
 
 		[Test]
 		[Test]
+		//!!! DO NOT REFORMAT THIS METHOD !!!
 		public void LongStrings()
 		public void LongStrings()
 		{
 		{
 			string script = @"    
 			string script = @"    
@@ -96,7 +155,7 @@ namespace MoonSharp.Interpreter.Tests
 			Assert.AreEqual(DataType.String, res.Tuple[0].Type);
 			Assert.AreEqual(DataType.String, res.Tuple[0].Type);
 			Assert.AreEqual(DataType.String, res.Tuple[1].Type);
 			Assert.AreEqual(DataType.String, res.Tuple[1].Type);
 			Assert.AreEqual(DataType.String, res.Tuple[2].Type);
 			Assert.AreEqual(DataType.String, res.Tuple[2].Type);
-			Assert.AreEqual("\t\t\t\t\tciao\r\n\t\t\t\t", res.Tuple[0].String);
+			Assert.AreEqual("\t\t\t\t\tciao\n\t\t\t\t", res.Tuple[0].String);
 			Assert.AreEqual(" [[uh]] ", res.Tuple[1].String);
 			Assert.AreEqual(" [[uh]] ", res.Tuple[1].String);
 			Assert.AreEqual("[==[[=[[[eheh]]=]=]", res.Tuple[2].String);
 			Assert.AreEqual("[==[[=[[[eheh]]=]=]", res.Tuple[2].String);
 		}
 		}
@@ -145,6 +204,7 @@ namespace MoonSharp.Interpreter.Tests
 		[Test]
 		[Test]
 		public void ParserErrorMessage()
 		public void ParserErrorMessage()
 		{
 		{
+			bool caught = false;
 			string script = @"    
 			string script = @"    
 				return 'It's a wet floor warning saying wheat flour instead. \
 				return 'It's a wet floor warning saying wheat flour instead. \
 				Probably, the cook thought it was funny. \
 				Probably, the cook thought it was funny. \
@@ -156,10 +216,25 @@ namespace MoonSharp.Interpreter.Tests
 			}
 			}
 			catch (SyntaxErrorException ex)
 			catch (SyntaxErrorException ex)
 			{
 			{
+				caught = true;
 				Assert.IsNotNullOrEmpty(ex.Message);
 				Assert.IsNotNullOrEmpty(ex.Message);
 			}
 			}
+
+			Assert.IsTrue(caught);
 		}
 		}
 
 
+		[Test]
+		public void StringsWithBackslashLineEndings2()
+		{
+			string script = @"    
+				return 'a\
+				b\
+				c'";
+
+			DynValue res = Script.RunString(script);
+
+			Assert.AreEqual(DataType.String, res.Type);
+		}
 
 
 		[Test]
 		[Test]
 		public void StringsWithBackslashLineEndings()
 		public void StringsWithBackslashLineEndings()
@@ -193,6 +268,27 @@ namespace MoonSharp.Interpreter.Tests
 		}
 		}
 
 
 
 
+		[Test]
+		public void ReturnSimpleUnop()
+		{
+			string script = @"return -42";
+
+			DynValue res = Script.RunString(script);
+
+			Assert.AreEqual(DataType.Number, res.Type);
+			Assert.AreEqual(-42, res.Number);
+		}
+
+		[Test]
+		public void ReturnSimple()
+		{
+			string script = @"return 42";
+
+			DynValue res = Script.RunString(script);
+
+			Assert.AreEqual(DataType.Number, res.Type);
+			Assert.AreEqual(42, res.Number);
+		}
 
 
 
 
 		[Test]
 		[Test]
@@ -616,7 +712,29 @@ namespace MoonSharp.Interpreter.Tests
 			Assert.AreEqual(12, res.Number);
 			Assert.AreEqual(12, res.Number);
 		}
 		}
 
 
+		[Test]
+		public void OperatorPrecedence6()
+		{
+			string script = @"return -2^2";
+			Script S = new Script(CoreModules.None);
+
+			DynValue res = S.DoString(script);
+
+			Assert.AreEqual(DataType.Number, res.Type);
+			Assert.AreEqual(-4, res.Number);
+		}
+
+		[Test]
+		public void OperatorPrecedence7()
+		{
+			string script = @"return -7 / 0.5";
+			Script S = new Script(CoreModules.None);
+
+			DynValue res = S.DoString(script);
 
 
+			Assert.AreEqual(DataType.Number, res.Type);
+			Assert.AreEqual(-14, res.Number);
+		}
 
 
 		[Test]
 		[Test]
 		public void OperatorPrecedenceAndAssociativity()
 		public void OperatorPrecedenceAndAssociativity()
@@ -792,6 +910,28 @@ namespace MoonSharp.Interpreter.Tests
 			Assert.AreEqual(DataType.Function, res.Type);
 			Assert.AreEqual(DataType.Function, res.Type);
 		}
 		}
 
 
+		[Test]
+		public void FunctionWithStringArg2()
+		{
+			string script = @"    
+				x = 0;
+
+				fact = function(y)
+					x = y
+				end
+
+				fact 'ciao';
+
+				return x;
+				";
+
+
+			DynValue res = Script.RunString(script);
+
+			Assert.AreEqual(DataType.String, res.Type);
+			Assert.AreEqual("ciao", res.String);
+		}
+
 		[Test]
 		[Test]
 		public void FunctionWithStringArg()
 		public void FunctionWithStringArg()
 		{
 		{
@@ -934,21 +1074,6 @@ namespace MoonSharp.Interpreter.Tests
 			Assert.AreEqual(1, res.Number);
 			Assert.AreEqual(1, res.Number);
 		}
 		}
 
 
-		[Test]
-		[ExpectedException(ExpectedException=typeof(SyntaxErrorException))]
-		public void HexFloatsReportError()
-		{
-			string script = @"
-					function x(a, b)
-			
-					end
-
-					x(0x0.1E, 0x1E / 0x100);
-								";
-
-			DynValue res = Script.RunString(script);
-		}
-
 
 
 		[Test]
 		[Test]
 		public void ExpressionReducesTuples2()
 		public void ExpressionReducesTuples2()
@@ -1262,7 +1387,7 @@ namespace MoonSharp.Interpreter.Tests
 		}
 		}
 
 
 		[Test]
 		[Test]
-		[ExpectedException(ExpectedException = typeof(SyntaxErrorException))]
+		[ExpectedException(typeof(SyntaxErrorException))]
 		public void VarArgsInNoVarArgsReturnsError()
 		public void VarArgsInNoVarArgsReturnsError()
 		{
 		{
 			string script = @"
 			string script = @"
@@ -1283,6 +1408,31 @@ namespace MoonSharp.Interpreter.Tests
 			DynValue res = Script.RunString(script);
 			DynValue res = Script.RunString(script);
 		}
 		}
 
 
+		[Test]
+		public void HexFloats_1()
+		{
+			string script = "return 0x0.1E";
+			DynValue result = Script.RunString(script);
+			Assert.AreEqual((double)0x1E / (double)0x100, result.Number);
+		}
+
+		[Test]
+		public void HexFloats_2()
+		{
+			string script = "return 0xA23p-4";
+			DynValue result = Script.RunString(script);
+			Assert.AreEqual((double)0xA23 / 16.0, result.Number);
+		}
+
+		[Test]
+		public void HexFloats_3()
+		{
+			string script = "return 0X1.921FB54442D18P+1";
+			DynValue result = Script.RunString(script);
+			Assert.AreEqual((1 + (double)0x921FB54442D18 / (double)0x10000000000000) * 2, result.Number);
+		}
+
+
 
 
 
 
 	}
 	}

+ 1 - 1
src/MoonSharp.Interpreter.Tests/EndToEnd/TableTests.cs

@@ -437,7 +437,7 @@ namespace MoonSharp.Interpreter.Tests
 			}
 			}
 		";
 		";
 
 
-			Script s = new Script();
+			Script s = new Script(CoreModules.None);
 			s.DoString(script);
 			s.DoString(script);
 
 
 			Assert.AreEqual("hello", s.Globals["t", "ciao", 1]);
 			Assert.AreEqual("hello", s.Globals["t", "ciao", 1]);

+ 10 - 0
src/MoonSharp.Interpreter.Tests/EndToEnd/UserDataMethodsTests.cs

@@ -185,6 +185,7 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 
 
 			SomeClass obj = new SomeClass();
 			SomeClass obj = new SomeClass();
 
 
+			UserData.UnregisterType<SomeClass>();
 			UserData.RegisterType<SomeClass>(opt);
 			UserData.RegisterType<SomeClass>(opt);
 
 
 			S.Globals.Set("static", UserData.CreateStatic<SomeClass>());
 			S.Globals.Set("static", UserData.CreateStatic<SomeClass>());
@@ -209,6 +210,7 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 
 
 			SomeClass obj = new SomeClass();
 			SomeClass obj = new SomeClass();
 
 
+			UserData.UnregisterType<SomeClass>();
 			UserData.RegisterType<SomeClass>(opt);
 			UserData.RegisterType<SomeClass>(opt);
 
 
 			S.Globals.Set("myobj", UserData.Create(obj));
 			S.Globals.Set("myobj", UserData.Create(obj));
@@ -232,6 +234,7 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 
 
 			SomeClass obj = new SomeClass();
 			SomeClass obj = new SomeClass();
 
 
+			UserData.UnregisterType<SomeClass>();
 			UserData.RegisterType<SomeClass>(opt);
 			UserData.RegisterType<SomeClass>(opt);
 
 
 			S.Globals.Set("myobj", UserData.Create(obj));
 			S.Globals.Set("myobj", UserData.Create(obj));
@@ -256,6 +259,7 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 
 
 			SomeClass obj = new SomeClass();
 			SomeClass obj = new SomeClass();
 
 
+			UserData.UnregisterType<SomeClass>();
 			UserData.RegisterType<SomeClass>(opt);
 			UserData.RegisterType<SomeClass>(opt);
 
 
 			S.Globals["mytype"] = typeof(SomeClass);
 			S.Globals["mytype"] = typeof(SomeClass);
@@ -281,6 +285,7 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 
 
 			SomeClass obj = new SomeClass();
 			SomeClass obj = new SomeClass();
 
 
+			UserData.UnregisterType<SomeClass>();
 			UserData.RegisterType<SomeClass>(opt);
 			UserData.RegisterType<SomeClass>(opt);
 
 
 			S.Globals["static"] = typeof(SomeClass);
 			S.Globals["static"] = typeof(SomeClass);
@@ -503,6 +508,8 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 
 
 			Script S = new Script();
 			Script S = new Script();
 
 
+			UserData.UnregisterType<Interface1>();
+			UserData.UnregisterType<Interface2>();
 			UserData.RegisterType<Interface1>();
 			UserData.RegisterType<Interface1>();
 			UserData.RegisterType<Interface2>();
 			UserData.RegisterType<Interface2>();
 
 
@@ -534,6 +541,7 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 
 
 			SomeClass obj = new SomeClass();
 			SomeClass obj = new SomeClass();
 
 
+			UserData.UnregisterType<SomeClass>();
 			UserData.RegisterType<SomeClass>();
 			UserData.RegisterType<SomeClass>();
 
 
 			S.Globals.Set("myobj", UserData.Create(obj));
 			S.Globals.Set("myobj", UserData.Create(obj));
@@ -562,6 +570,7 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 
 
 			SelfDescribingClass obj = new SelfDescribingClass();
 			SelfDescribingClass obj = new SelfDescribingClass();
 
 
+			UserData.UnregisterType<SelfDescribingClass>();
 			UserData.RegisterType<SelfDescribingClass>();
 			UserData.RegisterType<SelfDescribingClass>();
 
 
 			S.Globals.Set("myobj", UserData.Create(obj));
 			S.Globals.Set("myobj", UserData.Create(obj));
@@ -601,3 +610,4 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 
 
 	}
 	}
 }
 }
+

+ 11 - 1
src/MoonSharp.Interpreter.Tests/EndToEnd/UserDataPropertiesTests.cs

@@ -36,7 +36,8 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 			Script S = new Script();
 			Script S = new Script();
 
 
 			SomeClass obj = new SomeClass() {  IntProp = 321 };
 			SomeClass obj = new SomeClass() {  IntProp = 321 };
-			
+
+			UserData.UnregisterType<SomeClass>();
 			UserData.RegisterType<SomeClass>(opt);
 			UserData.RegisterType<SomeClass>(opt);
 
 
 			S.Globals.Set("myobj", UserData.Create(obj));
 			S.Globals.Set("myobj", UserData.Create(obj));
@@ -59,6 +60,7 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 			SomeClass obj1 = new SomeClass() { NIntProp = 321 };
 			SomeClass obj1 = new SomeClass() { NIntProp = 321 };
 			SomeClass obj2 = new SomeClass() { NIntProp = null };
 			SomeClass obj2 = new SomeClass() { NIntProp = null };
 
 
+			UserData.UnregisterType<SomeClass>();
 			UserData.RegisterType<SomeClass>(opt);
 			UserData.RegisterType<SomeClass>(opt);
 
 
 			S.Globals.Set("myobj1", UserData.Create(obj1));
 			S.Globals.Set("myobj1", UserData.Create(obj1));
@@ -85,6 +87,7 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 			SomeClass obj1 = new SomeClass() { ObjProp="ciao" };
 			SomeClass obj1 = new SomeClass() { ObjProp="ciao" };
 			SomeClass obj2 = new SomeClass() { ObjProp = obj1 };
 			SomeClass obj2 = new SomeClass() { ObjProp = obj1 };
 
 
+			UserData.UnregisterType<SomeClass>();
 			UserData.RegisterType<SomeClass>(opt);
 			UserData.RegisterType<SomeClass>(opt);
 
 
 			S.Globals.Set("myobj1", UserData.Create(obj1));
 			S.Globals.Set("myobj1", UserData.Create(obj1));
@@ -110,6 +113,7 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 
 
 			SomeClass obj = new SomeClass() { IntProp = 321 };
 			SomeClass obj = new SomeClass() { IntProp = 321 };
 
 
+			UserData.UnregisterType<SomeClass>();
 			UserData.RegisterType<SomeClass>(opt);
 			UserData.RegisterType<SomeClass>(opt);
 
 
 			S.Globals.Set("myobj", UserData.Create(obj));
 			S.Globals.Set("myobj", UserData.Create(obj));
@@ -132,6 +136,7 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 			SomeClass obj1 = new SomeClass() { NIntProp = 321 };
 			SomeClass obj1 = new SomeClass() { NIntProp = 321 };
 			SomeClass obj2 = new SomeClass() { NIntProp = null };
 			SomeClass obj2 = new SomeClass() { NIntProp = null };
 
 
+			UserData.UnregisterType<SomeClass>();
 			UserData.RegisterType<SomeClass>(opt);
 			UserData.RegisterType<SomeClass>(opt);
 
 
 			S.Globals.Set("myobj1", UserData.Create(obj1));
 			S.Globals.Set("myobj1", UserData.Create(obj1));
@@ -157,6 +162,7 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 			SomeClass obj1 = new SomeClass() { ObjProp = "ciao" };
 			SomeClass obj1 = new SomeClass() { ObjProp = "ciao" };
 			SomeClass obj2 = new SomeClass() { ObjProp = obj1 };
 			SomeClass obj2 = new SomeClass() { ObjProp = obj1 };
 
 
+			UserData.UnregisterType<SomeClass>();
 			UserData.RegisterType<SomeClass>(opt);
 			UserData.RegisterType<SomeClass>(opt);
 
 
 			S.Globals.Set("myobj1", UserData.Create(obj1));
 			S.Globals.Set("myobj1", UserData.Create(obj1));
@@ -180,6 +186,7 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 
 
 			SomeClass obj = new SomeClass() { IntProp = 321 };
 			SomeClass obj = new SomeClass() { IntProp = 321 };
 
 
+			UserData.UnregisterType<SomeClass>();
 			UserData.RegisterType<SomeClass>(opt);
 			UserData.RegisterType<SomeClass>(opt);
 
 
 			S.Globals.Set("myobj", UserData.Create(obj));
 			S.Globals.Set("myobj", UserData.Create(obj));
@@ -200,6 +207,7 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 
 
 			SomeClass.StaticProp = "qweqwe";
 			SomeClass.StaticProp = "qweqwe";
 
 
+			UserData.UnregisterType<SomeClass>();
 			UserData.RegisterType<SomeClass>(opt);
 			UserData.RegisterType<SomeClass>(opt);
 
 
 			S.Globals.Set("static", UserData.CreateStatic<SomeClass>());
 			S.Globals.Set("static", UserData.CreateStatic<SomeClass>());
@@ -225,6 +233,7 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 
 
 			SomeClass obj = new SomeClass();
 			SomeClass obj = new SomeClass();
 
 
+			UserData.UnregisterType<SomeClass>();
 			UserData.RegisterType<SomeClass>(opt);
 			UserData.RegisterType<SomeClass>(opt);
 
 
 			S.Globals.Set("myobj", UserData.Create(obj));
 			S.Globals.Set("myobj", UserData.Create(obj));
@@ -412,6 +421,7 @@ namespace MoonSharp.Interpreter.Tests.EndToEnd
 
 
 			SomeClass obj = new SomeClass() { IntProp = 321 };
 			SomeClass obj = new SomeClass() { IntProp = 321 };
 
 
+			UserData.UnregisterType<SomeClass>();
 			UserData.RegisterType<SomeClass>();
 			UserData.RegisterType<SomeClass>();
 
 
 			S.Globals["myobj"] = obj;
 			S.Globals["myobj"] = obj;

+ 0 - 116
src/MoonSharp.Interpreter.Tests/ErrorHandlingTests.cs

@@ -1,116 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using NUnit.Framework;
-
-namespace MoonSharp.Interpreter.Tests
-{
-	[TestFixture]
-	class ErrorHandlingTests
-	{
-		[Test]
-		public void Errors_PCall_ClrFunction()
-		{
-			string script = @"
-				r, msg = pcall(assert, false, 'catched')
-				return r, msg;
-								";
-
-			DynValue res = Script.RunString(script);
-
-			Assert.AreEqual(DataType.Tuple, res.Type);
-			Assert.AreEqual(2, res.Tuple.Length);
-			Assert.AreEqual(DataType.Boolean, res.Tuple[0].Type);
-			Assert.AreEqual(DataType.String, res.Tuple[1].Type);
-			Assert.AreEqual(false, res.Tuple[0].Boolean);
-		}
-
-		[Test]
-		public void Errors_PCall_Multiples()
-		{
-			string script = @"
-function try(fn)
-	local x, y = pcall(fn)
-	
-	if (x) then
-		return y
-	else
-		return '!'
-	end
-end
-
-function a()
-	return try(b) .. 'a';
-end
-
-function b()
-	return try(c) .. 'b';
-end
-
-function c()
-	return try(d) .. 'c';
-end
-
-function d()
-	local t = { } .. 'x'
-end
-
-
-return a()
-";
-
-			DynValue res = Script.RunString(script);
-
-			Assert.AreEqual(DataType.String, res.Type);
-			Assert.AreEqual("!cba", res.String);
-		}
-
-		[Test]
-		public void Errors_TryCatch_Multiples()
-		{
-			string script = @"
-function a()
-	return try(b) .. 'a';
-end
-
-function b()
-	return try(c) .. 'b';
-end
-
-function c()
-	return try(d) .. 'c';
-end
-
-function d()
-	local t = { } .. 'x'
-end
-
-
-return a()
-";
-			Script S = new Script(CoreModules.None);
-
-			S.Globals["try"] = DynValue.NewCallback((c, a) =>
-				{
-					try
-					{
-						var v = a[0].Function.Call();
-						return v;
-					}
-					catch(ScriptRuntimeException)
-					{
-						return DynValue.NewString("!");
-					}
-				});
-
-
-			DynValue res = S.DoString(script);
-
-			Assert.AreEqual(DataType.String, res.Type);
-			Assert.AreEqual("!cba", res.String);
-		}
-
-
-	}
-}

+ 9 - 7
src/MoonSharp.Interpreter.Tests/MoonSharp.Interpreter.Tests.csproj → src/MoonSharp.Interpreter.Tests/MoonSharp.Interpreter.Tests.net35-client.csproj

@@ -59,8 +59,9 @@
   </PropertyGroup>
   </PropertyGroup>
   <ItemGroup>
   <ItemGroup>
     <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
     <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
-    <Reference Include="nunit.framework">
-      <HintPath>..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
+    <Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
     </Reference>
     </Reference>
     <Reference Include="System" />
     <Reference Include="System" />
     <Reference Include="System.Core">
     <Reference Include="System.Core">
@@ -76,11 +77,13 @@
     <Otherwise />
     <Otherwise />
   </Choose>
   </Choose>
   <ItemGroup>
   <ItemGroup>
+    <Compile Include="EmbeddableNUnitWrapper.cs" />
     <Compile Include="EndToEnd\BinaryDumpTests.cs" />
     <Compile Include="EndToEnd\BinaryDumpTests.cs" />
     <Compile Include="EndToEnd\ClosureTests.cs" />
     <Compile Include="EndToEnd\ClosureTests.cs" />
     <Compile Include="EndToEnd\CoroutineTests.cs" />
     <Compile Include="EndToEnd\CoroutineTests.cs" />
     <Compile Include="EndToEnd\DynamicTests.cs" />
     <Compile Include="EndToEnd\DynamicTests.cs" />
     <Compile Include="EndToEnd\ErrorHandlingTests.cs" />
     <Compile Include="EndToEnd\ErrorHandlingTests.cs" />
+    <Compile Include="EndToEnd\GotoTests.cs" />
     <Compile Include="EndToEnd\LuaTestSuiteExtract.cs" />
     <Compile Include="EndToEnd\LuaTestSuiteExtract.cs" />
     <Compile Include="EndToEnd\MetatableTests.cs">
     <Compile Include="EndToEnd\MetatableTests.cs">
       <SubType>Code</SubType>
       <SubType>Code</SubType>
@@ -92,21 +95,20 @@
       <SubType>Code</SubType>
       <SubType>Code</SubType>
     </Compile>
     </Compile>
     <Compile Include="EndToEnd\Utils.cs" />
     <Compile Include="EndToEnd\Utils.cs" />
-    <Compile Include="ErrorHandlingTests.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="EndToEnd\SimpleTests.cs" />
     <Compile Include="EndToEnd\SimpleTests.cs" />
     <Compile Include="EndToEnd\TableTests.cs" />
     <Compile Include="EndToEnd\TableTests.cs" />
-    <Compile Include="TestMore\TapRunner.cs" />
-    <Compile Include="TestMore\TestMoreTests.cs" />
+    <Compile Include="TapRunner.cs" />
+    <Compile Include="TestMoreTests.cs" />
     <Compile Include="TestRunner.cs" />
     <Compile Include="TestRunner.cs" />
     <Compile Include="Units\BinDumpStreamTests.cs" />
     <Compile Include="Units\BinDumpStreamTests.cs" />
     <Compile Include="Units\FastStackTests.cs" />
     <Compile Include="Units\FastStackTests.cs" />
     <Compile Include="Units\InteropTests.cs" />
     <Compile Include="Units\InteropTests.cs" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
-    <ProjectReference Include="..\MoonSharp.Interpreter\MoonSharp.Interpreter.csproj">
+    <ProjectReference Include="..\MoonSharp.Interpreter\MoonSharp.Interpreter.net35-client.csproj">
       <Project>{91ea9b9d-fe03-4273-bdaf-8ad42ede1e59}</Project>
       <Project>{91ea9b9d-fe03-4273-bdaf-8ad42ede1e59}</Project>
-      <Name>MoonSharp.Interpreter</Name>
+      <Name>MoonSharp.Interpreter.net35-client</Name>
     </ProjectReference>
     </ProjectReference>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>

+ 2 - 2
src/MoonSharp.Interpreter.Tests/Properties/AssemblyInfo.cs

@@ -17,10 +17,10 @@ using System.Runtime.InteropServices;
 // Setting ComVisible to false makes the types in this assembly not visible 
 // Setting ComVisible to false makes the types in this assembly not visible 
 // to COM components.  If you need to access a type in this assembly from 
 // to COM components.  If you need to access a type in this assembly from 
 // COM, set the ComVisible attribute to true on that type.
 // COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
+//[assembly: ComVisible(false)]
 
 
 // The following GUID is for the ID of the typelib if this project is exposed to COM
 // The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("2d45e616-2c1d-4458-b68c-734ef4616028")]
+//[assembly: Guid("2d45e616-2c1d-4458-b68c-734ef4616028")]
 
 
 // Version information for an assembly consists of the following four values:
 // Version information for an assembly consists of the following four values:
 //
 //

+ 27 - 9
src/MoonSharp.Interpreter.Tests/TestMore/TapRunner.cs → src/MoonSharp.Interpreter.Tests/TapRunner.cs

@@ -1,15 +1,33 @@
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
+using System.Diagnostics;
 using System.IO;
 using System.IO;
 using System.Linq;
 using System.Linq;
+using System.Reflection;
 using System.Text;
 using System.Text;
 using MoonSharp.Interpreter.CoreLib;
 using MoonSharp.Interpreter.CoreLib;
 using MoonSharp.Interpreter.Execution;
 using MoonSharp.Interpreter.Execution;
 using MoonSharp.Interpreter.Loaders;
 using MoonSharp.Interpreter.Loaders;
+using MoonSharp.Interpreter.Platforms;
 using NUnit.Framework;
 using NUnit.Framework;
 
 
 namespace MoonSharp.Interpreter.Tests
 namespace MoonSharp.Interpreter.Tests
 {
 {
+#if !EMBEDTEST
+	class TestsScriptLoader : ScriptLoaderBase
+	{
+		public override bool ScriptFileExists(string name)
+		{
+			return File.Exists(name);
+		}
+
+		public override object LoadFile(string file, Table globalContext)
+		{
+			return new FileStream(file, FileMode.Open, FileAccess.Read);
+		}
+	}
+#endif
+
 	public class TapRunner
 	public class TapRunner
 	{
 	{
 		string m_File;
 		string m_File;
@@ -28,22 +46,22 @@ namespace MoonSharp.Interpreter.Tests
 		{
 		{
 			Script S = new Script();
 			Script S = new Script();
 
 
-			//S.Globals["print"] = DynValue.NewCallback(Print);
 			S.Options.DebugPrint = Print;
 			S.Options.DebugPrint = Print;
 
 
 			S.Options.UseLuaErrorLocations = true;
 			S.Options.UseLuaErrorLocations = true;
 
 
-			S.Globals.Set("arg", DynValue.NewTable(S));
+#if PCL
+	#if EMBEDTEST
+			S.Options.ScriptLoader = new EmbeddedResourcesScriptLoader(Assembly.GetExecutingAssembly());
+	#else
+			S.Options.ScriptLoader = new TestsScriptLoader();
+	#endif
+#endif
 
 
-			ClassicLuaScriptLoader L = S.Options.ScriptLoader as ClassicLuaScriptLoader;
+			S.Globals.Set("arg", DynValue.NewTable(S));
 
 
-			if (L == null)
-			{
-				L = new ClassicLuaScriptLoader();
-				S.Options.ScriptLoader = L;
-			}
+			((ScriptLoaderBase)S.Options.ScriptLoader).ModulePaths = new string[] { "TestMore/Modules/?", "TestMore/Modules/?.lua" };
 
 
-			L.ModulePaths = L.UnpackStringPaths("TestMore/Modules/?;TestMore/Modules/?.lua");
 			S.DoFile(m_File);
 			S.DoFile(m_File);
 		}
 		}
 
 

+ 14 - 22
src/MoonSharp.Interpreter.Tests/TestMore/203-lexico.t

@@ -44,7 +44,7 @@ is(string.byte("\t"), 9)
 is(string.byte("\v"), 11)
 is(string.byte("\v"), 11)
 is(string.byte("\\"), 92)
 is(string.byte("\\"), 92)
 
 
-is(string.len("A\0B"), 3, "chk")
+is(string.len("A\0B"), 3)
 
 
 f, msg = load [[a = "A\300"]]
 f, msg = load [[a = "A\300"]]
 like(msg, "^[^:]+:%d+: .- escape .- near")
 like(msg, "^[^:]+:%d+: .- escape .- near")
@@ -55,29 +55,25 @@ like(msg, "^[^:]+:%d+: .- near")
 f, msg = load [[a = "A\Z"]]
 f, msg = load [[a = "A\Z"]]
 like(msg, "^[^:]+:%d+: .- escape .- near")
 like(msg, "^[^:]+:%d+: .- escape .- near")
 
 
--- MoonSharp - changed tests because of different parser bail out errors
-
 f, msg = load [[a = " unfinished string ]]
 f, msg = load [[a = " unfinished string ]]
-like(msg, ".+")
+like(msg, "^[^:]+:%d+: unfinished string near")
 
 
 f, msg = load [[a = " unfinished string
 f, msg = load [[a = " unfinished string
 ]]
 ]]
-like(msg, ".+")
+like(msg, "^[^:]+:%d+: unfinished string near")
 
 
 f, msg = load [[a = " unfinished string \
 f, msg = load [[a = " unfinished string \
 ]]
 ]]
-like(msg, ".+")
+like(msg, "^[^:]+:%d+: unfinished string near")
 
 
 f, msg = load [[a = " unfinished string \]]
 f, msg = load [[a = " unfinished string \]]
-like(msg, ".+")
+like(msg, "^[^:]+:%d+: unfinished string near")
 
 
 f, msg = load "a = [[ unfinished long string "
 f, msg = load "a = [[ unfinished long string "
-like(msg, ".+")
+like(msg, "^[^:]+:%d+: unfinished long string near")
 
 
 f, msg = load "a = [== invalid long string delimiter "
 f, msg = load "a = [== invalid long string delimiter "
-like(msg, ".+")
-
--- End of MoonSharp changes
+like(msg, "^[^:]+:%d+: invalid long string delimiter near")
 
 
 a = 'alo\n123"'
 a = 'alo\n123"'
 is('alo\n123"', a)
 is('alo\n123"', a)
@@ -89,27 +85,23 @@ is([==[
 alo
 alo
 123"]==], a)
 123"]==], a)
 is("alo\n\z
 is("alo\n\z
-    123\"", a)
+123\"", a)
 
 
 f, msg = load [[a = " escape \z unauthorized
 f, msg = load [[a = " escape \z unauthorized
 new line" ]]
 new line" ]]
-like(msg, "^[^:]+:%d+: .+") -- MoonSharp changed error msg
+like(msg, "^[^:]+:%d+: unfinished string near")
 
 
 is(3.0, 3)
 is(3.0, 3)
 is(314.16e-2, 3.1416)
 is(314.16e-2, 3.1416)
 is(0.31416E1, 3.1416)
 is(0.31416E1, 3.1416)
 is(0xff, 255)
 is(0xff, 255)
 is(0x56, 86)
 is(0x56, 86)
---[[
-MoonSharp : no intention to support hex floats
-
- is(0x0.1E, 0x1E / 0x100, "hexf1")        -- 0.1171875
-is(0xA23p-4, 0xA23 / (2^4), "hexf2")     -- 162.1875
-is(0X1.921FB54442D18P+1, (1 + 0x921FB54442D18/0x10000000000000) * 2, "hexf3")
---]]
+is(0x0.1E, 0x1E / 0x100)        -- 0.1171875
+is(0xA23p-4, 0xA23 / (2^4))     -- 162.1875
+is(0X1.921FB54442D18P+1, (1 + 0x921FB54442D18/0x10000000000000) * 2)
 
 
 f, msg = load [[a = 12e34e56]]
 f, msg = load [[a = 12e34e56]]
-like(msg, ".+") -- MoonSharp changed error msg
+like(msg, "^[^:]+:%d+: malformed number near")
 
 
 --[===[
 --[===[
 --[[
 --[[
@@ -120,7 +112,7 @@ like(msg, ".+") -- MoonSharp changed error msg
 --]===]
 --]===]
 
 
 f, msg = load "  --[[ unfinished long comment "
 f, msg = load "  --[[ unfinished long comment "
-like(msg, ".+")
+like(msg, "^[^:]+:%d+: unfinished long comment near")
 
 
 -- Local Variables:
 -- Local Variables:
 --   mode: lua
 --   mode: lua

+ 2 - 2
src/MoonSharp.Interpreter.Tests/TestMore/214-coroutine.t

@@ -130,7 +130,7 @@ end)
 eq_array({co("Hello")}, {"Hello"})
 eq_array({co("Hello")}, {"Hello"})
 eq_array({co("World")}, {true, "World"})
 eq_array({co("World")}, {true, "World"})
 
 
---[[
+--[[ ]]
 co = coroutine.wrap(function(...)
 co = coroutine.wrap(function(...)
   function backtrace ()
   function backtrace ()
     return 'not a back trace'
     return 'not a back trace'
@@ -141,7 +141,7 @@ co = coroutine.wrap(function(...)
 end)
 end)
 eq_array({co("Hello")}, {"Hello"})
 eq_array({co("Hello")}, {"Hello"})
 eq_array({co("World")}, {true, "World"})
 eq_array({co("World")}, {true, "World"})
-]]
+
 
 
 --[[ ]]
 --[[ ]]
 local output = {}
 local output = {}

+ 5 - 1
src/MoonSharp.Interpreter.Tests/TestMore/304-string.t

@@ -54,7 +54,11 @@ error_like(function () string.char(0, 'bad') end,
            "function char (bad arg)")
            "function char (bad arg)")
 
 
 		   
 		   
---[[		   MoonSharp intentional : string.dump not supported, unicode chars supported!
+--[[		   
+MoonSharp intentional : 
+
+1) unicode chars supported!
+2) plan has upvalues, and by Lua spec it shouldn't be supported!
 		   
 		   
 error_like(function () string.char(0, 9999) end,
 error_like(function () string.char(0, 9999) end,
            "^[^:]+:%d+: bad argument #2 to 'char' %(.-value.-%)",
            "^[^:]+:%d+: bad argument #2 to 'char' %(.-value.-%)",

+ 7 - 2
src/MoonSharp.Interpreter.Tests/TestMore/305-table.t

@@ -171,7 +171,7 @@ for name, line in pairsByKeys(lines, function (a, b) return a < b end) do
 end
 end
 eq_array(output, {'luaH_get', 24, 'luaH_present', 48, 'luaH_set', 10}, "function sort")
 eq_array(output, {'luaH_get', 24, 'luaH_present', 48, 'luaH_set', 10}, "function sort")
 
 
---[[ +++ Commented for coroutines
+
 
 
 function permgen (a, n)
 function permgen (a, n)
     n = n or #a
     n = n or #a
@@ -223,6 +223,11 @@ eq_array(output, {
     'a b c d e f g', 5040,
     'a b c d e f g', 5040,
 }, "function sort (all permutations)")
 }, "function sort (all permutations)")
 
 
+--[[
+
+MoonSharp: Sort callbacks work --]]
+
+
 error_like(function ()
 error_like(function ()
     local t = { 1 }
     local t = { 1 }
     table.sort( { t, t, t, t, }, function (a, b) return a[1] == b[1] end )
     table.sort( { t, t, t, t, }, function (a, b) return a[1] == b[1] end )
@@ -230,6 +235,7 @@ error_like(function ()
            "^[^:]+:%d+: invalid order function for sorting",
            "^[^:]+:%d+: invalid order function for sorting",
            "function sort (bad func)")
            "function sort (bad func)")
 
 
+
 eq_array({table.unpack({})}, {}, "function unpack")
 eq_array({table.unpack({})}, {}, "function unpack")
 eq_array({table.unpack({'a'})}, {'a'})
 eq_array({table.unpack({'a'})}, {'a'})
 eq_array({table.unpack({'a','b','c'})}, {'a','b','c'})
 eq_array({table.unpack({'a','b','c'})}, {'a','b','c'})
@@ -245,4 +251,3 @@ eq_array({table.unpack({'a','b','c'},2,4)}, {'b','c'})
 -- vim: ft=lua expandtab shiftwidth=4:
 -- vim: ft=lua expandtab shiftwidth=4:
 
 
 
 
---]]

+ 59 - 55
src/MoonSharp.Interpreter.Tests/TestMore/TestMoreTests.cs → src/MoonSharp.Interpreter.Tests/TestMoreTests.cs

@@ -2,7 +2,6 @@
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Text;
 using System.Text;
-using MoonSharp.Interpreter.RuntimeAbstraction;
 using NUnit.Framework;
 using NUnit.Framework;
 
 
 namespace MoonSharp.Interpreter.Tests
 namespace MoonSharp.Interpreter.Tests
@@ -13,49 +12,49 @@ namespace MoonSharp.Interpreter.Tests
 		[Test]
 		[Test]
 		public void TestMore_000_sanity()
 		public void TestMore_000_sanity()
 		{
 		{
-			TapRunner.Run(@"TestMore\000-sanity.t");
+			TapRunner.Run(@"TestMore/000-sanity.t");
 		}
 		}
 
 
 
 
 		[Test]
 		[Test]
 		public void TestMore_001_if()
 		public void TestMore_001_if()
 		{
 		{
-			TapRunner.Run(@"TestMore\001-if.t");
+			TapRunner.Run(@"TestMore/001-if.t");
 		}
 		}
 
 
 
 
 		[Test]
 		[Test]
 		public void TestMore_002_table()
 		public void TestMore_002_table()
 		{
 		{
-			TapRunner.Run(@"TestMore\002-table.t");
+			TapRunner.Run(@"TestMore/002-table.t");
 		}
 		}
 
 
 
 
 		[Test]
 		[Test]
 		public void TestMore_011_while()
 		public void TestMore_011_while()
 		{
 		{
-			TapRunner.Run(@"TestMore\011-while.t");
+			TapRunner.Run(@"TestMore/011-while.t");
 		}
 		}
 
 
 
 
 		[Test]
 		[Test]
 		public void TestMore_012_repeat()
 		public void TestMore_012_repeat()
 		{
 		{
-			TapRunner.Run(@"TestMore\012-repeat.t");
+			TapRunner.Run(@"TestMore/012-repeat.t");
 		}
 		}
 
 
 
 
 		[Test]
 		[Test]
 		public void TestMore_014_fornum()
 		public void TestMore_014_fornum()
 		{
 		{
-			TapRunner.Run(@"TestMore\014-fornum.t");
+			TapRunner.Run(@"TestMore/014-fornum.t");
 		}
 		}
 
 
 
 
 		[Test]
 		[Test]
 		public void TestMore_015_forlist()
 		public void TestMore_015_forlist()
 		{
 		{
-			TapRunner.Run(@"TestMore\015-forlist.t");
+			TapRunner.Run(@"TestMore/015-forlist.t");
 		}
 		}
 
 
 
 
@@ -63,49 +62,49 @@ namespace MoonSharp.Interpreter.Tests
 		//[Ignore]
 		//[Ignore]
 		public void TestMore_101_boolean()
 		public void TestMore_101_boolean()
 		{
 		{
-			TapRunner.Run(@"TestMore\101-boolean.t");
+			TapRunner.Run(@"TestMore/101-boolean.t");
 		}
 		}
 
 
 
 
 		[Test] 
 		[Test] 
 		public void TestMore_102_function()
 		public void TestMore_102_function()
 		{
 		{
-			TapRunner.Run(@"TestMore\102-function.t");
+			TapRunner.Run(@"TestMore/102-function.t");
 		}
 		}
 
 
 
 
 		[Test]
 		[Test]
 		public void TestMore_103_nil()
 		public void TestMore_103_nil()
 		{
 		{
-			TapRunner.Run(@"TestMore\103-nil.t");
+			TapRunner.Run(@"TestMore/103-nil.t");
 		}
 		}
 
 
 
 
 		[Test]
 		[Test]
 		public void TestMore_104_number()
 		public void TestMore_104_number()
 		{
 		{
-			TapRunner.Run(@"TestMore\104-number.t");
+			TapRunner.Run(@"TestMore/104-number.t");
 		}
 		}
 
 
 
 
 		[Test]
 		[Test]
 		public void TestMore_105_string()
 		public void TestMore_105_string()
 		{
 		{
-			TapRunner.Run(@"TestMore\105-string.t");
+			TapRunner.Run(@"TestMore/105-string.t");
 		}
 		}
 
 
 
 
 		[Test]
 		[Test]
 		public void TestMore_106_table()
 		public void TestMore_106_table()
 		{
 		{
-			TapRunner.Run(@"TestMore\106-table.t");
+			TapRunner.Run(@"TestMore/106-table.t");
 		}
 		}
 
 
 
 
 		[Test]
 		[Test]
 		public void TestMore_107_thread()
 		public void TestMore_107_thread()
 		{
 		{
-			TapRunner.Run(@"TestMore\107-thread.t");
+			TapRunner.Run(@"TestMore/107-thread.t");
 		}
 		}
 
 
 
 
@@ -115,156 +114,160 @@ namespace MoonSharp.Interpreter.Tests
 		// end to end tests.
 		// end to end tests.
 		//public void TestMore_108_userdata()
 		//public void TestMore_108_userdata()
 		//{
 		//{
-		//	TapRunner.Run(@"TestMore\108-userdata.t");
+		//	TapRunner.Run(@"TestMore/108-userdata.t");
 		//}
 		//}
 
 
 
 
 		[Test]
 		[Test]
 		public void TestMore_200_examples()
 		public void TestMore_200_examples()
 		{
 		{
-			TapRunner.Run(@"TestMore\200-examples.t");
+			TapRunner.Run(@"TestMore/200-examples.t");
 		}
 		}
 
 
 
 
 		[Test]
 		[Test]
 		public void TestMore_201_assign()
 		public void TestMore_201_assign()
 		{
 		{
-			TapRunner.Run(@"TestMore\201-assign.t");
+			TapRunner.Run(@"TestMore/201-assign.t");
 		}
 		}
 
 
 
 
 		[Test]
 		[Test]
 		public void TestMore_202_expr()
 		public void TestMore_202_expr()
 		{
 		{
-			TapRunner.Run(@"TestMore\202-expr.t");
+			TapRunner.Run(@"TestMore/202-expr.t");
 		}
 		}
 
 
 
 
-		//[Test]
-		//[Ignore] // Failing because of handling of syntax error messages + goto/labels not implemented
-		//public void TestMore_203_lexico()
-		//{
-		//	TapRunner.Run(@"TestMore\203-lexico.t");
-		//}
+		[Test]
+		public void TestMore_203_lexico()
+		{
+			TapRunner.Run(@"TestMore/203-lexico.t");
+		}
 
 
-		//[Test]
-		//[Ignore] // Failing because of handling of syntax error messages
-		//public void TestMore_204_grammar()
-		//{
-		//	TapRunner.Run(@"TestMore\204-grammar.t");
-		//}
+		[Test]
+		public void TestMore_204_grammar()
+		{
+			TapRunner.Run(@"TestMore/204-grammar.t");
+		}
 
 
 		[Test]
 		[Test]
 		public void TestMore_211_scope()
 		public void TestMore_211_scope()
 		{
 		{
-			TapRunner.Run(@"TestMore\211-scope.t");
+			TapRunner.Run(@"TestMore/211-scope.t");
 		}
 		}
 
 
 
 
 		[Test]
 		[Test]
 		public void TestMore_212_function()
 		public void TestMore_212_function()
 		{
 		{
-			TapRunner.Run(@"TestMore\212-function.t");
+			TapRunner.Run(@"TestMore/212-function.t");
 		}
 		}
 
 
 
 
 		[Test]
 		[Test]
 		public void TestMore_213_closure()
 		public void TestMore_213_closure()
 		{
 		{
-			TapRunner.Run(@"TestMore\213-closure.t");
+			TapRunner.Run(@"TestMore/213-closure.t");
 		}
 		}
 
 
 
 
 		[Test]
 		[Test]
 		public void TestMore_214_coroutine()
 		public void TestMore_214_coroutine()
 		{
 		{
-			TapRunner.Run(@"TestMore\214-coroutine.t");
+			TapRunner.Run(@"TestMore/214-coroutine.t");
 		}
 		}
 
 
 
 
 		[Test]
 		[Test]
 		public void TestMore_221_table()
 		public void TestMore_221_table()
 		{
 		{
-			TapRunner.Run(@"TestMore\221-table.t");
+			TapRunner.Run(@"TestMore/221-table.t");
 		}
 		}
 
 
 
 
 		[Test]
 		[Test]
 		public void TestMore_222_constructor()
 		public void TestMore_222_constructor()
 		{
 		{
-			TapRunner.Run(@"TestMore\222-constructor.t");
+			TapRunner.Run(@"TestMore/222-constructor.t");
 		}
 		}
 
 
 
 
 		[Test]
 		[Test]
 		public void TestMore_223_iterator()
 		public void TestMore_223_iterator()
 		{
 		{
-			TapRunner.Run(@"TestMore\223-iterator.t");
+			TapRunner.Run(@"TestMore/223-iterator.t");
 		}
 		}
 
 
 
 
 		[Test]
 		[Test]
 		public void TestMore_231_metatable()
 		public void TestMore_231_metatable()
 		{
 		{
-			TapRunner.Run(@"TestMore\231-metatable.t");
+			TapRunner.Run(@"TestMore/231-metatable.t");
 		}
 		}
 
 
 
 
 		[Test]
 		[Test]
 		public void TestMore_232_object()
 		public void TestMore_232_object()
 		{
 		{
-			TapRunner.Run(@"TestMore\232-object.t");
+			TapRunner.Run(@"TestMore/232-object.t");
 		}
 		}
 
 
 
 
 		[Test]
 		[Test]
 		public void TestMore_301_basic()
 		public void TestMore_301_basic()
 		{
 		{
-			TapRunner.Run(@"TestMore\301-basic.t");
+			TapRunner.Run(@"TestMore/301-basic.t");
 		}
 		}
 
 
 		[Test]
 		[Test]
 		public void TestMore_304_string()
 		public void TestMore_304_string()
 		{
 		{
-			TapRunner.Run(@"TestMore\304-string.t");
+			TapRunner.Run(@"TestMore/304-string.t");
 		}
 		}
 
 
 		[Test]
 		[Test]
 		public void TestMore_305_table()
 		public void TestMore_305_table()
 		{
 		{
-			TapRunner.Run(@"TestMore\305-table.t");
+			TapRunner.Run(@"TestMore/305-table.t");
 		}
 		}
 
 
 
 
 		[Test]
 		[Test]
 		public void TestMore_306_math()
 		public void TestMore_306_math()
 		{
 		{
-			TapRunner.Run(@"TestMore\306-math.t");
+			TapRunner.Run(@"TestMore/306-math.t");
 		}
 		}
 
 
 		[Test]
 		[Test]
 		public void TestMore_307_bit()
 		public void TestMore_307_bit()
 		{
 		{
-			TapRunner.Run(@"TestMore\307-bit.t");
+			TapRunner.Run(@"TestMore/307-bit.t");
 		}
 		}
 
 
 		[Test]
 		[Test]
 		public void TestMore_308_io()
 		public void TestMore_308_io()
 		{
 		{
-			if (!Platform.Current.AreCoreModulesFullySupported(CoreModules.OS_System | CoreModules.IO))
-				throw new SkipThisTestException();
+			if (AreCoreModulesFullySupported(CoreModules.OS_System | CoreModules.IO))
+				TapRunner.Run(@"TestMore/308-io.t");
+			else
+				TestRunner.Skip();
+		}
 
 
-			TapRunner.Run(@"TestMore\308-io.t");
+		private bool AreCoreModulesFullySupported(CoreModules modules)
+		{
+			CoreModules supp = Script.Platform.FilterSupportedCoreModules(modules);
+			return supp == modules;
 		}
 		}
 
 
 
 
 		[Test]
 		[Test]
 		public void TestMore_309_os()
 		public void TestMore_309_os()
 		{
 		{
-			if (!Platform.Current.AreCoreModulesFullySupported(CoreModules.OS_System | CoreModules.IO))
-				throw new SkipThisTestException();
-
-			TapRunner.Run(@"TestMore\309-os.t");
+			if (AreCoreModulesFullySupported(CoreModules.OS_System | CoreModules.IO))
+				TapRunner.Run(@"TestMore/309-os.t");
+			else
+				TestRunner.Skip();
 		}
 		}
 
 
 
 
@@ -272,22 +275,23 @@ namespace MoonSharp.Interpreter.Tests
 		//[Ignore]
 		//[Ignore]
 		//public void TestMore_310_debug()
 		//public void TestMore_310_debug()
 		//{
 		//{
-		//	TapRunner.Run(@"TestMore\310-debug.t");
+		//	TapRunner.Run(@"TestMore/310-debug.t");
 		//}
 		//}
 
 
 
 
 		[Test]
 		[Test]
 		public void TestMore_314_regex()
 		public void TestMore_314_regex()
 		{
 		{
-			TapRunner.Run(@"TestMore\314-regex.t");
+			TapRunner.Run(@"TestMore/314-regex.t");
 		}
 		}
 
 
 		//[Test]
 		//[Test]
 		//[Ignore]
 		//[Ignore]
 		//public void TestMore_320_stdin()
 		//public void TestMore_320_stdin()
 		//{
 		//{
-		//	TapRunner.Run(@"TestMore\310-stdin.t");
+		//	TapRunner.Run(@"TestMore/310-stdin.t");
 		//}
 		//}
 
 
 	}
 	}
 }
 }
+

+ 20 - 4
src/MoonSharp.Interpreter.Tests/TestRunner.cs

@@ -3,7 +3,6 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Reflection;
 using System.Reflection;
 using System.Text;
 using System.Text;
-using MoonSharp.Interpreter.RuntimeAbstraction;
 using NUnit.Framework;
 using NUnit.Framework;
 
 
 namespace MoonSharp.Interpreter.Tests
 namespace MoonSharp.Interpreter.Tests
@@ -30,23 +29,34 @@ namespace MoonSharp.Interpreter.Tests
 	{
 	{
 		Action<TestResult> loggerAction;
 		Action<TestResult> loggerAction;
 
 
+		public static bool IsRunning { get; private set; }
+
 		public TestRunner(Action<TestResult> loggerAction)
 		public TestRunner(Action<TestResult> loggerAction)
 		{
 		{
+			IsRunning = true; 
+
 			this.loggerAction = loggerAction;
 			this.loggerAction = loggerAction;
 
 
-			Console_WriteLine("MoonSharp Test Suite Runner - {0} [{1}]", Script.VERSION, Platform.Current.Name);
+			Console_WriteLine("MoonSharp Test Suite Runner - {0} [{1}]", Script.VERSION, Script.Platform.GetPlatformName());
 			Console_WriteLine("http://www.moonsharp.org");
 			Console_WriteLine("http://www.moonsharp.org");
 			Console_WriteLine("");
 			Console_WriteLine("");
 		}
 		}
 
 
 		public void Test(string whichTest = null)
 		public void Test(string whichTest = null)
+		{
+			foreach (TestResult tr in IterateOnTests(whichTest))
+				loggerAction(tr);
+		}
+
+
+		public IEnumerable<TestResult> IterateOnTests(string whichTest = null)
 		{
 		{
 			int ok = 0;
 			int ok = 0;
 			int fail = 0;
 			int fail = 0;
 			int total = 0;
 			int total = 0;
 			int skipped = 0;
 			int skipped = 0;
 
 
-			Assembly asm = Assembly.GetAssembly(typeof(SimpleTests));
+			Assembly asm = Assembly.GetExecutingAssembly();
 
 
 			foreach (Type t in asm.GetTypes().Where(t => t.GetCustomAttributes(typeof(TestFixtureAttribute), true).Any()))
 			foreach (Type t in asm.GetTypes().Where(t => t.GetCustomAttributes(typeof(TestFixtureAttribute), true).Any()))
 			{
 			{
@@ -69,7 +79,7 @@ namespace MoonSharp.Interpreter.Tests
 						++total;
 						++total;
 					}
 					}
 
 
-					loggerAction(tr);
+					yield return tr;
 				}
 				}
 			}
 			}
 
 
@@ -162,5 +172,11 @@ namespace MoonSharp.Interpreter.Tests
 				}
 				}
 			}
 			}
 		}
 		}
+
+		internal static void Skip()
+		{
+			if (TestRunner.IsRunning)
+				throw new SkipThisTestException();
+		}
 	}
 	}
 }
 }

+ 173 - 0
src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/MoonSharp.Interpreter.Tests.Embeddable.portable40.csproj

@@ -0,0 +1,173 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{28B8B747-5683-46C0-B308-62E6D3C2F4CB}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>MoonSharp.Interpreter.Tests</RootNamespace>
+    <AssemblyName>MoonSharp.Interpreter.Tests</AssemblyName>
+    <DefaultLanguage>en-US</DefaultLanguage>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <TargetFrameworkProfile>Profile328</TargetFrameworkProfile>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>TRACE;DEBUG;PCL,EMBEDTEST</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE;PCL,EMBEDTEST</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\..\MoonSharp.Interpreter\_Projects\MoonSharp.Interpreter.portable40\MoonSharp.Interpreter.portable40.csproj">
+      <Project>{49f32476-fca0-45fd-8f89-0c7c0d15e409}</Project>
+      <Name>MoonSharp.Interpreter.portable40</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="..\..\EmbeddableNUnitWrapper.cs">
+      <Link>EmbeddableNUnitWrapper.cs</Link>
+    </Compile>
+    <Compile Include="..\..\EndToEnd\BinaryDumpTests.cs">
+      <Link>BinaryDumpTests.cs</Link>
+    </Compile>
+    <Compile Include="..\..\EndToEnd\ClosureTests.cs">
+      <Link>ClosureTests.cs</Link>
+    </Compile>
+    <Compile Include="..\..\EndToEnd\CoroutineTests.cs">
+      <Link>CoroutineTests.cs</Link>
+    </Compile>
+    <Compile Include="..\..\EndToEnd\DynamicTests.cs">
+      <Link>DynamicTests.cs</Link>
+    </Compile>
+    <Compile Include="..\..\EndToEnd\ErrorHandlingTests.cs">
+      <Link>ErrorHandlingTests.cs</Link>
+    </Compile>
+    <Compile Include="..\..\EndToEnd\GotoTests.cs">
+      <Link>GotoTests.cs</Link>
+    </Compile>
+    <Compile Include="..\..\EndToEnd\LuaTestSuiteExtract.cs">
+      <Link>LuaTestSuiteExtract.cs</Link>
+    </Compile>
+    <Compile Include="..\..\EndToEnd\MetatableTests.cs">
+      <SubType>Code</SubType>
+      <Link>MetatableTests.cs</Link>
+    </Compile>
+    <Compile Include="..\..\EndToEnd\StringLibTests.cs">
+      <Link>StringLibTests.cs</Link>
+    </Compile>
+    <Compile Include="..\..\EndToEnd\TailCallTests.cs">
+      <Link>TailCallTests.cs</Link>
+    </Compile>
+    <Compile Include="..\..\EndToEnd\UserDataMethodsTests.cs">
+      <Link>UserDataMethodsTests.cs</Link>
+    </Compile>
+    <Compile Include="..\..\EndToEnd\UserDataPropertiesTests.cs">
+      <SubType>Code</SubType>
+      <Link>UserDataPropertiesTests.cs</Link>
+    </Compile>
+    <Compile Include="..\..\EndToEnd\Utils.cs">
+      <Link>Utils.cs</Link>
+    </Compile>
+    <Compile Include="..\..\Properties\AssemblyInfo.cs">
+      <Link>AssemblyInfo.cs</Link>
+    </Compile>
+    <Compile Include="..\..\EndToEnd\SimpleTests.cs">
+      <Link>SimpleTests.cs</Link>
+    </Compile>
+    <Compile Include="..\..\EndToEnd\TableTests.cs">
+      <Link>TableTests.cs</Link>
+    </Compile>
+    <Compile Include="..\..\TapRunner.cs">
+      <Link>TapRunner.cs</Link>
+    </Compile>
+    <Compile Include="..\..\TestMoreTests.cs">
+      <Link>TestMoreTests.cs</Link>
+    </Compile>
+    <Compile Include="..\..\TestRunner.cs">
+      <Link>TestRunner.cs</Link>
+    </Compile>
+    <Compile Include="..\..\Units\BinDumpStreamTests.cs">
+      <Link>BinDumpStreamTests.cs</Link>
+    </Compile>
+    <Compile Include="..\..\Units\FastStackTests.cs">
+      <Link>FastStackTests.cs</Link>
+    </Compile>
+    <Compile Include="..\..\Units\InteropTests.cs">
+      <Link>InteropTests.cs</Link>
+    </Compile>
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="TestMore\000-sanity.t" />
+    <EmbeddedResource Include="TestMore\001-if.t" />
+    <EmbeddedResource Include="TestMore\002-table.t" />
+    <EmbeddedResource Include="TestMore\011-while.t" />
+    <EmbeddedResource Include="TestMore\012-repeat.t" />
+    <EmbeddedResource Include="TestMore\014-fornum.t" />
+    <EmbeddedResource Include="TestMore\015-forlist.t" />
+    <EmbeddedResource Include="TestMore\101-boolean.t" />
+    <EmbeddedResource Include="TestMore\102-function.t" />
+    <EmbeddedResource Include="TestMore\103-nil.t" />
+    <EmbeddedResource Include="TestMore\104-number.t" />
+    <EmbeddedResource Include="TestMore\105-string.t" />
+    <EmbeddedResource Include="TestMore\106-table.t" />
+    <EmbeddedResource Include="TestMore\107-thread.t" />
+    <EmbeddedResource Include="TestMore\108-userdata.t" />
+    <EmbeddedResource Include="TestMore\200-examples.t" />
+    <EmbeddedResource Include="TestMore\201-assign.t" />
+    <EmbeddedResource Include="TestMore\202-expr.t" />
+    <EmbeddedResource Include="TestMore\203-lexico.t" />
+    <EmbeddedResource Include="TestMore\204-grammar.t" />
+    <EmbeddedResource Include="TestMore\211-scope.t" />
+    <EmbeddedResource Include="TestMore\212-function.t" />
+    <EmbeddedResource Include="TestMore\213-closure.t" />
+    <EmbeddedResource Include="TestMore\214-coroutine.t" />
+    <EmbeddedResource Include="TestMore\221-table.t" />
+    <EmbeddedResource Include="TestMore\222-constructor.t" />
+    <EmbeddedResource Include="TestMore\223-iterator.t" />
+    <EmbeddedResource Include="TestMore\231-metatable.t" />
+    <EmbeddedResource Include="TestMore\232-object.t" />
+    <EmbeddedResource Include="TestMore\301-basic.t" />
+    <EmbeddedResource Include="TestMore\304-string.t" />
+    <EmbeddedResource Include="TestMore\305-table.t" />
+    <EmbeddedResource Include="TestMore\306-math.t" />
+    <EmbeddedResource Include="TestMore\307-bit.t" />
+    <EmbeddedResource Include="TestMore\308-io.t" />
+    <EmbeddedResource Include="TestMore\309-os.t" />
+    <EmbeddedResource Include="TestMore\310-debug.t" />
+    <EmbeddedResource Include="TestMore\314-regex.t" />
+    <EmbeddedResource Include="TestMore\320-stdin.t" />
+    <EmbeddedResource Include="TestMore\Modules\Test\Builder.lua">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </EmbeddedResource>
+    <EmbeddedResource Include="TestMore\Modules\Test\More.lua">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </EmbeddedResource>
+  </ItemGroup>
+  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 30 - 0
src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/Properties/AssemblyInfo.cs

@@ -0,0 +1,30 @@
+using System.Resources;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("MoonSharp.Interpreter.Tests.Embeddable.portable40")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("MoonSharp.Interpreter.Tests.Embeddable.portable40")]
+[assembly: AssemblyCopyright("Copyright ©  2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+[assembly: NeutralResourcesLanguage("en")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 54 - 0
src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/000-sanity.t

@@ -0,0 +1,54 @@
+#! /usr/bin/lua
+--
+-- lua-TestMore : <http://fperrad.github.com/lua-TestMore/>
+--
+-- Copyright (C) 2009, Perrad Francois
+--
+-- This code is licensed under the terms of the MIT/X11 license,
+-- like Lua itself.
+--
+
+--[[
+
+=head1 Lua test suite
+
+=head2 Synopsis
+
+    % prove 000-sanity.t
+
+=head2 Description
+
+=cut
+
+]]
+
+function f (n)
+    return n + 1
+end
+
+function g (m, p)
+    return m + p
+end
+
+print('1..9')
+print("ok 1 -")
+print('ok', 2, "- list")
+print("ok " .. 3 .. " - concatenation")
+i = 4
+print("ok " .. i .. " - var")
+i = i + 1
+print("ok " .. i .. " - var incr")
+print("ok " .. i+1 .. " - expr")
+j = f(i + 1)
+print("ok " .. j .. " - call f")
+k = g(i, 3)
+print("ok " .. k .. " - call g")
+local print = print
+print("ok 9 - local")
+
+-- Local Variables:
+--   mode: lua
+--   lua-indent-level: 4
+--   fill-column: 100
+-- End:
+-- vim: ft=lua expandtab shiftwidth=4:

+ 87 - 0
src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/001-if.t

@@ -0,0 +1,87 @@
+#! /usr/bin/lua
+--
+-- lua-TestMore : <http://fperrad.github.com/lua-TestMore/>
+--
+-- Copyright (C) 2009-2010, Perrad Francois
+--
+-- This code is licensed under the terms of the MIT/X11 license,
+-- like Lua itself.
+--
+
+--[[
+
+=head1 Lua if statement
+
+=head2 Synopsis
+
+    % prove 001-if.t
+
+=head2 Description
+
+See "Lua 5.2 Reference Manual", section 3.3.4 "Control Structures",
+L<http://www.lua.org/manual/5.2/manual.html#3.3.4>.
+
+See "Programming in Lua", section 4.3 "Control Structures".
+
+=cut
+
+]]
+
+print("1..6")
+
+if true then
+    print("ok 1")
+else
+    print("not ok 1")
+end
+
+if not true then
+    print("not ok 2")
+else
+    print("ok 2")
+end
+
+a = 12
+b = 34
+if a < b then
+    print("ok 3")
+else
+    print("not ok 3")
+end
+
+a = 0
+b = 4
+if a < b then
+    print("ok 4")
+elseif a == b then
+    print("not ok 4")
+else
+    print("not ok 4")
+end
+
+a = 5
+b = 5
+if a < b then
+    print("not ok 5")
+elseif a == b then
+    print("ok 5")
+else
+    print("not ok 5")
+end
+
+a = 10
+b = 6
+if a < b then
+    print("not ok 6")
+elseif a == b then
+    print("not ok 6")
+else
+    print("ok 6")
+end
+
+-- Local Variables:
+--   mode: lua
+--   lua-indent-level: 4
+--   fill-column: 100
+-- End:
+-- vim: ft=lua expandtab shiftwidth=4:

+ 67 - 0
src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/002-table.t

@@ -0,0 +1,67 @@
+#! /usr/bin/lua
+--
+-- lua-TestMore : <http://fperrad.github.com/lua-TestMore/>
+--
+-- Copyright (C) 2009, Perrad Francois
+--
+-- This code is licensed under the terms of the MIT/X11 license,
+-- like Lua itself.
+--
+
+--[[
+
+=head1 Lua table
+
+=head2 Synopsis
+
+    % prove 002-table.t
+
+=head2 Description
+
+See "Programming in Lua", section 2.5 "Tables".
+
+=cut
+
+]]
+
+print("1..8")
+
+a = {"ok 1", "ok 2", "ok 3"}
+print(a[1])
+i = 2
+print(a[i])
+print(a[i+1])
+if #a == 3 then
+    print("ok 4 - len")
+else
+    print("not ok 4")
+end
+if a[7] == nil then
+    print("ok 5")
+else
+    print("not ok 5")
+end
+
+t = {a=10, b=100}
+if t['a'] == 10 then
+    print("ok 6")
+else
+    print("not ok 6")
+end
+if t.b == 100 then
+    print("ok 7")
+else
+    print("not ok 7")
+end
+if t.z == nil then
+    print("ok 8")
+else
+    print("not ok 8")
+end
+
+-- Local Variables:
+--   mode: lua
+--   lua-indent-level: 4
+--   fill-column: 100
+-- End:
+-- vim: ft=lua expandtab shiftwidth=4:

+ 80 - 0
src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/011-while.t

@@ -0,0 +1,80 @@
+#! /usr/bin/lua
+--
+-- lua-TestMore : <http://fperrad.github.com/lua-TestMore/>
+--
+-- Copyright (C) 2009-2010, Perrad Francois
+--
+-- This code is licensed under the terms of the MIT/X11 license,
+-- like Lua itself.
+--
+
+--[[
+
+=head1 Lua while statement
+
+=head2 Synopsis
+
+    % prove 011-while.t
+
+=head2 Description
+
+See "Lua 5.2 Reference Manual", section 3.3.4 "Control Structures",
+L<http://www.lua.org/manual/5.2/manual.html#3.3.4>.
+
+See "Programming in Lua", section 4.3 "Control Structures".
+
+=cut
+
+]]
+
+print("1..11")
+
+a = {}
+local i = 1
+while a[i] do
+    i = i + 1
+end
+if i == 1 then
+    print("ok 1 - while empty")
+else
+    print("not ok 1 - " .. i)
+end
+
+a = {"ok 2 - while ", "ok 3", "ok 4"}
+local i = 1
+while a[i] do
+    print(a[i])
+    i = i + 1
+end
+
+a = {"ok 5 - with break", "ok 6", "stop", "more"}
+local i = 1
+while a[i] do
+    if a[i] == 'stop' then break end
+    print(a[i])
+    i = i + 1
+end
+if i == 3 then
+    print("ok 7 - break")
+else
+    print("not ok 7 - " .. i)
+end
+
+x = 3
+local i = 1
+while i<=x do
+    print("ok " .. 7+i)
+    i = i + 1
+end
+if i == 4 then
+    print("ok 11")
+else
+    print("not ok 11 - " .. i)
+end
+
+-- Local Variables:
+--   mode: lua
+--   lua-indent-level: 4
+--   fill-column: 100
+-- End:
+-- vim: ft=lua expandtab shiftwidth=4:

+ 78 - 0
src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/012-repeat.t

@@ -0,0 +1,78 @@
+#! /usr/bin/lua
+--
+-- lua-TestMore : <http://fperrad.github.com/lua-TestMore/>
+--
+-- Copyright (C) 2009-2010, Perrad Francois
+--
+-- This code is licensed under the terms of the MIT/X11 license,
+-- like Lua itself.
+--
+
+--[[
+
+=head1 Lua repeat statement
+
+=head2 Synopsis
+
+    % prove 012-repeat.t
+
+=head2 Description
+
+See "Lua 5.2 Reference Manual", section 3.3.4 "Control Structures",
+L<http://www.lua.org/manual/5.2/manual.html#3.3.4>.
+
+See "Programming in Lua", section 4.3 "Control Structures".
+
+=cut
+
+]]
+
+print("1..8")
+
+a = {"ok 1 - repeat", "ok 2", "ok 3"}
+local i = 0
+repeat
+    i = i + 1
+    if a[i] then
+        print(a[i])
+    end
+until not a[i]
+if i == 4 then
+    print("ok 4")
+else
+    print("not ok 4 - " .. i)
+end
+
+a = {"ok 5 - with break", "ok 6", 'stop', 'more'}
+local i = 0
+repeat
+    i = i + 1
+    if a[i] == 'stop' then break end
+    print(a[i])
+until not a[i]
+if a[i] == 'stop' then
+    print("ok 7 - break")
+else
+    print("not ok 7 - " .. a[i])
+end
+
+function f () return true end
+
+local i = 1
+repeat
+    local v = f()
+    if i == 1 then
+        print("ok 8 - scope")
+    else
+        print("not ok")
+        break
+    end
+    i = i + 1
+until v
+
+-- Local Variables:
+--   mode: lua
+--   lua-indent-level: 4
+--   fill-column: 100
+-- End:
+-- vim: ft=lua expandtab shiftwidth=4:

+ 136 - 0
src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/014-fornum.t

@@ -0,0 +1,136 @@
+#! /usr/bin/lua
+--
+-- lua-TestMore : <http://fperrad.github.com/lua-TestMore/>
+--
+-- Copyright (C) 2009-2013, Perrad Francois
+--
+-- This code is licensed under the terms of the MIT/X11 license,
+-- like Lua itself.
+--
+
+--[[
+
+=head1 Lua for statement
+
+=head2 Synopsis
+
+    % prove 014-fornum.t
+
+=head2 Description
+
+See "Lua 5.2 Reference Manual", section 3.3.5 "For Statement",
+L<http://www.lua.org/manual/5.2/manual.html#3.3.5>.
+
+See "Programming in Lua", section 4.3 "Control Structures".
+
+=cut
+
+--]]
+
+print("1..36")
+
+for i = 1, 10, 2 do
+    print("ok " .. (i+1)/2 .. " - for 1, 10, 2")
+end
+
+for i = 1, 10, 2 do
+    function f ()
+        print("ok " .. (i+11)/2 .. " - for 1, 10, 2 lex")
+    end
+    f()
+end
+
+function f (i)
+    print("ok " .. (i+21)/2 .. " - for 1, 10, 2 !lex")
+end
+for i = 1, 10, 2 do
+    f(i)
+end
+
+for i = 3, 5 do
+    print("ok " .. 13+i .. " - for 3, 5")
+    i = i + 1
+end
+
+for i = 5, 1, -1 do
+    print("ok " .. 24-i .. " - for 5, 1, -1")
+end
+
+for i = 5, 5 do
+    print("ok " .. 19+i .. " - for 5, 5")
+end
+
+for i = 5, 5, -1 do
+    print("ok " .. 20+i .. " - for 5, 5, -1")
+end
+
+v = false
+for i = 5, 3 do
+    v = true
+end
+if v then
+    print("not ok 26 - for 5, 3")
+else
+    print("ok 26 - for 5, 3")
+end
+
+v = false
+for i = 5, 7, -1 do
+    v = true
+end
+if v then
+    print("not ok 27 - for 5, 7, -1")
+else
+    print("ok 27 - for 5, 7, -1")
+end
+
+v = false
+for i = 5, 7, 0 do
+    v = true
+    break -- avoid infinite loop with luajit
+end
+if jit then
+    print("not ok 28 - for 5, 7, 0 # TODO # LuaJIT intentional.")
+elseif v then
+    print("not ok 28 - for 5, 7, 0")
+else
+    print("ok 28 - for 5, 7, 0")
+end
+
+v = nil
+for i = 1, 10, 2 do
+    if i > 4 then break end
+    print("ok " .. (i+57)/2 .. " - for break")
+    v = i
+end
+if v == 3 then
+    print("ok 31 - break")
+else
+    print("not ok 31 - " .. v)
+end
+
+local function first() return 1 end
+local function limit() return 8 end
+local function step()  return 2 end
+for i = first(), limit(), step() do
+    print("ok " .. (i+63)/2 .. " - with functions")
+end
+
+local a = {}
+for i = 1, 10 do
+    a[i] = function () return i end
+end
+local v = a[5]()
+if v == 5 then
+    print("ok 36 - for & upval")
+else
+    print("not ok 36 - for & upval")
+    print("#", v)
+end
+
+-- Local Variables:
+--   mode: lua
+--   lua-indent-level: 4
+--   fill-column: 100
+-- End:
+-- vim: ft=lua expandtab shiftwidth=4:

+ 99 - 0
src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/015-forlist.t

@@ -0,0 +1,99 @@
+#! /usr/bin/lua
+--
+-- lua-TestMore : <http://fperrad.github.com/lua-TestMore/>
+--
+-- Copyright (C) 2009-2010, Perrad Francois
+--
+-- This code is licensed under the terms of the MIT/X11 license,
+-- like Lua itself.
+--
+
+--[[
+
+=head1 Lua for statement
+
+=head2 Synopsis
+
+    % prove 015-forlist.t
+
+=head2 Description
+
+See "Lua 5.2 Reference Manual", section 3.3.5 "For Statement",
+L<http://www.lua.org/manual/5.2/manual.html#3.3.5>.
+
+See "Programming in Lua", section 4.3 "Control Structures".
+
+=cut
+
+--]]
+
+print("1..18")
+
+a = {"ok 1 - for ipairs", "ok 2 - for ipairs", "ok 3 - for ipairs"}
+for _, v in ipairs(a) do
+    print(v)
+end
+for i, v in ipairs(a) do
+    print("ok " .. 3+i .. " - for ipairs")
+end
+
+r = false
+t = {a=10, b=100}
+for i, v in ipairs(t) do
+    print(i, v)
+    r = true
+end
+if r then
+    print("not ok 7 - for ipairs (hash)")
+else
+    print("ok 7 - for ipairs (hash)")
+end
+
+for k in pairs(a) do
+    print("ok " .. 7+k .. " - for pairs")
+end
+
+local i = 1
+for k in pairs(t) do
+    if k == 'a' or k == 'b' then
+        print("ok " .. 10+i .. " - for pairs (hash)")
+    else
+        print("not ok " .. 10+i .. " - " .. k)
+    end
+    i = i + 1
+end
+
+a = {"ok 13 - for break", "ok 14 - for break", "stop", "more"}
+local i
+for _, v in ipairs(a) do
+    if v == "stop" then break end
+    print(v)
+    i = _
+end
+if i == 2 then
+    print("ok 15 - break")
+else
+    print("not ok 15 - " .. i)
+end
+
+local a = {"ok 16 - for & upval", "ok 17 - for & upval", "ok 18 - for & upval"}
+local b = {}
+for i, v in ipairs(a) do
+    b[i] = function () return v end
+end
+for i, v in ipairs(a) do
+    local r = b[i]()
+    if r == a[i] then
+        print(r)
+    else
+        print("not " .. a[i])
+        print("#", r)
+    end
+end
+
+-- Local Variables:
+--   mode: lua
+--   lua-indent-level: 4
+--   fill-column: 100
+-- End:
+-- vim: ft=lua expandtab shiftwidth=4:

+ 120 - 0
src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/101-boolean.t

@@ -0,0 +1,120 @@
+#! /usr/bin/lua
+--
+-- lua-TestMore : <http://fperrad.github.com/lua-TestMore/>
+--
+-- Copyright (C) 2009, Perrad Francois
+--
+-- This code is licensed under the terms of the MIT/X11 license,
+-- like Lua itself.
+--
+
+--[[
+
+=head1  Lua boolean & coercion
+
+=head2 Synopsis
+
+    % prove 101-boolean.t
+
+=head2 Description
+
+=cut
+
+]]
+
+require 'Test.More'
+
+plan(24)
+
+error_like(function () return -true end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a %w+ value",
+           "-true")
+
+error_like(function () return #true end,
+           "^[^:]+:%d+: attempt to get length of a boolean value",
+           "#true")
+
+is(not false, true, "not false")
+
+error_like(function () return true + 10 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a boolean value",
+           "true + 10")
+
+error_like(function () return true - 2 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a boolean value",
+           "true - 2")
+
+error_like(function () return true * 3.14 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a boolean value",
+           "true * 3.14")
+
+error_like(function () return true / -7 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a boolean value",
+           "true / -7")
+
+error_like(function () return true % 4 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a boolean value",
+           "true % 4")
+
+error_like(function () return true ^ 3 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a boolean value",
+           "true ^ 3")
+
+error_like(function () return true .. 'end' end,
+           "^[^:]+:%d+: attempt to concatenate a boolean value",
+           "true .. 'end'")
+
+is(true == true, true, "true == true")
+
+is(true ~= false, true, "true ~= false")
+
+is(true == 1, false, "true == 1")
+
+is(true ~= 1, true, "true ~= 1")
+
+error_like(function () return true < false end,
+           "^[^:]+:%d+: attempt to compare two boolean values",
+           "true < false")
+
+error_like(function () return true <= false end,
+           "^[^:]+:%d+: attempt to compare two boolean values",
+           "true <= false")
+
+error_like(function () return true > false end,
+           "^[^:]+:%d+: attempt to compare two boolean values",
+           "true > false")
+
+error_like(function () return true >= false end,
+           "^[^:]+:%d+: attempt to compare two boolean values",
+           "true >= false")
+
+error_like(function () return true < 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "true < 0")
+
+error_like(function () return true <= 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "true <= 0")
+
+error_like(function () return true > 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "true > 0")
+
+error_like(function () return true >= 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "true >= 0")
+
+error_like(function () a = true; b = a[1]; end,
+           "^[^:]+:%d+: attempt to index",
+           "index")
+
+error_like(function () a = true; a[1] = 1; end,
+           "^[^:]+:%d+: attempt to index",
+           "index")
+
+-- Local Variables:
+--   mode: lua
+--   lua-indent-level: 4
+--   fill-column: 100
+-- End:
+-- vim: ft=lua expandtab shiftwidth=4:

+ 199 - 0
src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/102-function.t

@@ -0,0 +1,199 @@
+#! /usr/bin/lua
+--
+-- lua-TestMore : <http://fperrad.github.com/lua-TestMore/>
+--
+-- Copyright (C) 2009-2011, Perrad Francois
+--
+-- This code is licensed under the terms of the MIT/X11 license,
+-- like Lua itself.
+--
+
+--[[
+
+=head1 Lua function & coercion
+
+=head2 Synopsis
+
+    % prove 102-function.t
+
+=head2 Description
+
+=cut
+
+--]]
+
+require 'Test.More'
+
+plan(51)
+
+f = function () return 1 end
+
+error_like(function () return -f end,
+           "^[^:]+:%d+: attempt to perform arithmetic on",
+           "-f")
+
+error_like(function () f = print; return -f end,
+           "^[^:]+:%d+: attempt to perform arithmetic on")
+
+error_like(function () return #f end,
+           "^[^:]+:%d+: attempt to get length of",
+           "#f")
+
+error_like(function () f = print; return #f end,
+           "^[^:]+:%d+: attempt to get length of")
+
+is(not f, false, "not f")
+
+is(not print, false)
+
+error_like(function () return f + 10 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on",
+           "f + 10")
+
+error_like(function () f = print; return f + 10 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on")
+
+error_like(function () return f - 2 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on",
+           "f - 2")
+
+error_like(function () f = print; return f - 2 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on")
+
+error_like(function () return f * 3.14 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on",
+           "f * 3.14")
+
+error_like(function () f = print; return f * 3.14 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on")
+
+error_like(function () return f / -7 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on",
+           "f / -7")
+
+error_like(function () f = print; return f / -7 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on")
+
+error_like(function () return f % 4 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on",
+           "f % 4")
+
+error_like(function () f = print; return f % 4 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on")
+
+error_like(function () return f ^ 3 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on",
+           "f ^ 3")
+
+error_like(function () f = print; return f ^ 3 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on")
+
+error_like(function () return f .. 'end' end,
+           "^[^:]+:%d+: attempt to concatenate",
+           "f .. 'end'")
+
+error_like(function () f = print; return f .. 'end' end,
+           "^[^:]+:%d+: attempt to concatenate")
+
+g = f
+is(f == g, true, "f == f")
+
+g = print
+is(g == print, true)
+
+g = function () return 2 end
+is(f ~= g, true, "f ~= g")
+h = type
+is(f ~= h, true)
+
+is(print ~= g, true)
+is(print ~= h, true)
+
+is(f == 1, false, "f == 1")
+
+is(print == 1, false)
+
+is(f ~= 1, true, "f ~= 1")
+
+is(print ~= 1, true)
+
+error_like(function () return f < g end,
+           "^[^:]+:%d+: attempt to compare two function values",
+           "f < g")
+
+error_like(function () f = print; g = type; return f < g end,
+           "^[^:]+:%d+: attempt to compare two function values")
+
+error_like(function () return f <= g end,
+           "^[^:]+:%d+: attempt to compare two function values",
+           "f <= g")
+
+error_like(function () f = print; g = type; return f <= g end,
+           "^[^:]+:%d+: attempt to compare two function values")
+
+error_like(function () return f > g end,
+           "^[^:]+:%d+: attempt to compare two function values",
+           "f > g")
+
+error_like(function () f = print; g = type; return f > g end,
+           "^[^:]+:%d+: attempt to compare two function values")
+
+error_like(function () return f >= g end,
+           "^[^:]+:%d+: attempt to compare two function values",
+           "f >= g")
+
+error_like(function () f = print; g = type; return f >= g end,
+           "^[^:]+:%d+: attempt to compare two function values")
+
+error_like(function () return f < 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "f < 0")
+
+error_like(function () f = print; return f < 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+")
+
+error_like(function () return f <= 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "f <= 0")
+
+error_like(function () f = print; return f <= 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+")
+
+error_like(function () return f > 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "f > 0")
+
+error_like(function () f = print; return f > 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+")
+
+error_like(function () return f > 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "f >= 0")
+
+error_like(function () f = print; return f >= 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+")
+
+error_like(function () a = f; b = a[1]; end,
+           "^[^:]+:%d+: attempt to index",
+           "index")
+
+error_like(function () a = print; b = a[1]; end,
+           "^[^:]+:%d+: attempt to index")
+
+error_like(function () a = f; a[1] = 1; end,
+           "^[^:]+:%d+: attempt to index",
+           "index")
+
+error_like(function () a = print; a[1] = 1; end,
+           "^[^:]+:%d+: attempt to index")
+
+t = {}
+t[print] = true
+ok(t[print])
+
+-- Local Variables:
+--   mode: lua
+--   lua-indent-level: 4
+--   fill-column: 100
+-- End:
+-- vim: ft=lua expandtab shiftwidth=4:

+ 120 - 0
src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/103-nil.t

@@ -0,0 +1,120 @@
+#! /usr/bin/lua
+--
+-- lua-TestMore : <http://fperrad.github.com/lua-TestMore/>
+--
+-- Copyright (C) 2009, Perrad Francois
+--
+-- This code is licensed under the terms of the MIT/X11 license,
+-- like Lua itself.
+--
+
+--[[
+
+=head1 Lua nil & coercion
+
+=head2 Synopsis
+
+    % prove 103-nil.t
+
+=head2 Description
+
+=cut
+
+--]]
+
+require 'Test.More'
+
+plan(24)
+
+error_like(function () return -nil end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a nil value",
+           "-nil")
+
+error_like(function () return #nil end,
+           "^[^:]+:%d+: attempt to get length of a nil value",
+           "#nil")
+
+is(not nil, true, "not nil")
+
+error_like(function () return nil + 10 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a nil value",
+           "nil + 10")
+
+error_like(function () return nil - 2 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a nil value",
+           "nil - 2")
+
+error_like(function () return nil * 3.14 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a nil value",
+           "nil * 3.14")
+
+error_like(function () return nil / -7 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a nil value",
+           "nil / -7")
+
+error_like(function () return nil % 4 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a nil value",
+           "nil % 4")
+
+error_like(function () return nil ^ 3 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a nil value",
+           "nil ^ 3")
+
+error_like(function () return nil .. 'end' end,
+           "^[^:]+:%d+: attempt to concatenate a nil value",
+           "nil .. 'end'")
+
+is(nil == nil, true, "nil == nil")
+
+is(nil ~= nil, false, "nil ~= nil")
+
+is(nil == 1, false, "nil == 1")
+
+is(nil ~= 1, true, "nil ~= 1")
+
+error_like(function () return nil < nil end,
+           "^[^:]+:%d+: attempt to compare two nil values",
+           "nil < nil")
+
+error_like(function () return nil <= nil end,
+           "^[^:]+:%d+: attempt to compare two nil values",
+           "nil <= nil")
+
+error_like(function () return nil > nil end,
+           "^[^:]+:%d+: attempt to compare two nil values",
+           "nil > nil")
+
+error_like(function () return nil > nil end,
+           "^[^:]+:%d+: attempt to compare two nil values",
+           "nil >= nil")
+
+error_like(function () return nil < 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "nil < 0")
+
+error_like(function () return nil <= 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "nil <= 0")
+
+error_like(function () return nil > 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "nil > 0")
+
+error_like(function () return nil >= 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "nil >= 0")
+
+error_like(function () a = nil; b = a[1]; end,
+           "^[^:]+:%d+: attempt to index",
+           "index")
+
+error_like(function () a = nil; a[1] = 1; end,
+           "^[^:]+:%d+: attempt to index",
+           "index")
+
+-- Local Variables:
+--   mode: lua
+--   lua-indent-level: 4
+--   fill-column: 100
+-- End:
+-- vim: ft=lua expandtab shiftwidth=4:

+ 190 - 0
src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/104-number.t

@@ -0,0 +1,190 @@
+#! /usr/bin/lua
+--
+-- lua-TestMore : <http://fperrad.github.com/lua-TestMore/>
+--
+-- Copyright (C) 2009, Perrad Francois
+--
+-- This code is licensed under the terms of the MIT/X11 license,
+-- like Lua itself.
+--
+
+--[[
+
+=head1 Lua number & coercion
+
+=head2 Synopsis
+
+    % prove 104-number.t
+
+=head2 Description
+
+=cut
+
+--]]
+
+require 'Test.More'
+
+plan(54)
+
+is(-1, -(1), "-1")
+
+error_like(function () return #1 end,
+           "^[^:]+:%d+: attempt to get length of a number value",
+           "#1")
+
+is(not 1, false, "not 1")
+
+is(10 + 2, 12, "10 + 2")
+
+is(2 - 10, -8, "2 - 10")
+
+is(3.14 * 1, 3.14, "3.14 * 1")
+
+is(-7 / 0.5, -14, "-7 / 0.5")
+
+type_ok(1 / 0, 'number', "1 / 0")
+
+is(-25 % 3, 2, "-25 % 3")
+
+type_ok(1 % 0, 'number', "1 % 0")
+
+error_like(function () return 10 + true end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a boolean value",
+           "10 + true")
+
+error_like(function () return 2 - nil end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a nil value",
+           "2 - nil")
+
+error_like(function () return 3.14 * false end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a boolean value",
+           "3.14 * false")
+
+error_like(function () return -7 / {} end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a table value",
+           "-7 / {}")
+
+error_like(function () return 3 ^ true end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a boolean value",
+           "3 ^ true")
+
+error_like(function () return -25 % false end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a boolean value",
+           "-25 % false")
+
+error_like(function () return 10 + 'text' end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a string value",
+           "10 + 'text'")
+
+error_like(function () return 2 - 'text' end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a string value",
+           "2 - 'text'")
+
+error_like(function () return 3.14 * 'text' end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a string value",
+           "3.14 * 'text'")
+
+error_like(function () return -7 / 'text' end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a string value",
+           "-7 / 'text'")
+
+error_like(function () return 25 % 'text' end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a string value",
+           "25 % 'text'")
+
+error_like(function () return 3 ^ 'text' end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a string value",
+           "3 ^ 'text'")
+
+is(10 + '2', 12, "10 + '2'")
+
+is(2 - '10', -8, "2 - '10'")
+
+is(3.14 * '1', 3.14, "3.14 * '1'")
+
+is(-7 / '0.5', -14, "-7 / '0.5'")
+
+is(-25 % '3', 2, "-25 % '3'")
+
+is(3 ^ '3', 27, "3 ^ '3'")
+
+is(1 .. 'end', '1end', "1 .. 'end'")
+
+is(1 .. 2, '12', "1 .. 2")
+
+error_like(function () return 1 .. true end,
+           "^[^:]+:%d+: attempt to concatenate a %w+ value",
+           "1 .. true")
+
+is(1.0 == 1, true, "1.0 == 1")
+
+is(1 ~= 2, true, "1 ~= 2")
+
+is(1 == true, false, "1 == true")
+
+is(1 ~= nil, true, "1 ~= nil")
+
+is(1 == '1', false, "1 == '1'")
+
+is(1 ~= '1', true, "1 ~= '1'")
+
+is(1 < 0, false, "1 < 0")
+
+is(1 <= 0, false, "1 <= 0")
+
+is(1 > 0, true, "1 > 0")
+
+is(1 >= 0, true, "1 >= 0")
+
+error_like(function () return 1 < false end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "1 < false")
+
+error_like(function () return 1 <= nil end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "1 <= nil")
+
+error_like(function () return 1 > true end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "1 > true")
+
+error_like(function () return 1 >= {} end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "1 >= {}")
+
+error_like(function () return 1 < '0' end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "1 < '0'")
+
+error_like(function () return 1 <= '0' end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "1 <= '0'")
+
+error_like(function () return 1 > '0' end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "1 > '0'")
+
+error_like(function () return 1 >= '0' end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "1 >= '0'")
+
+is(tostring(1000000000), '1000000000', "number 1000000000")
+
+is(tostring(1e9), '1000000000', "number 1e9")
+
+is(tostring(1.0e+9), '1000000000', "number 1.0e+9")
+
+error_like(function () a= 3.14; b = a[1]; end,
+           "^[^:]+:%d+: attempt to index",
+           "index")
+
+error_like(function () a = 3.14; a[1] = 1; end,
+           "^[^:]+:%d+: attempt to index",
+           "index")
+
+-- Local Variables:
+--   mode: lua
+--   lua-indent-level: 4
+--   fill-column: 100
+-- End:
+-- vim: ft=lua expandtab shiftwidth=4:

+ 183 - 0
src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/105-string.t

@@ -0,0 +1,183 @@
+#! /usr/bin/lua
+--
+-- lua-TestMore : <http://fperrad.github.com/lua-TestMore/>
+--
+-- Copyright (C) 2009-2011, Perrad Francois
+--
+-- This code is licensed under the terms of the MIT/X11 license,
+-- like Lua itself.
+--
+
+--[[
+
+=head1 Lua string & coercion
+
+=head2 Synopsis
+
+    % prove 105-string.t
+
+=head2 Description
+
+=cut
+
+--]]
+
+require 'Test.More'
+
+plan(51)
+
+is(- '1', -1, "-'1'")
+
+error_like(function () return - 'text' end,
+           "^[^:]+:%d+: attempt to perform arithmetic on .- string value",
+           "-'text'")
+
+is(# 'text', 4, "#'text'")
+
+is(not 'text', false, "not 'text'")
+
+is('10' + 2, 12, "'10' + 2")
+
+is('2' - 10, -8, "'2' - 10")
+
+is('3.14' * 1, 3.14, "'3.14' * 1")
+
+is('-7' / 0.5, -14, "'-7' / 0.5")
+
+is('-25' % 3, 2, "'-25' % 3")
+
+is('3' ^ 3, 27, "'3' ^ 3")
+
+error_like(function () return '10' + true end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a boolean value",
+           "'10' + true")
+
+error_like(function () return '2' - nil end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a nil value",
+           "'2' - nil")
+
+error_like(function () return '3.14' * false end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a boolean value",
+           "'3.14' * false")
+
+error_like(function () return '-7' / {} end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a table value",
+           "'-7' / {}")
+
+error_like(function () return '-25' % false end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a boolean value",
+           "'-25' % false")
+
+error_like(function () return '3' ^ true end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a boolean value",
+           "'3' ^ true")
+
+error_like(function () return '10' + 'text' end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a string value",
+           "'10' + 'text'")
+
+error_like(function () return '2' - 'text' end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a string value",
+           "'2' - 'text'")
+
+error_like(function () return '3.14' * 'text' end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a string value",
+           "'3.14' * 'text'")
+
+error_like(function () return '-7' / 'text' end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a string value",
+           "'-7' / 'text'")
+
+error_like(function () return '-25' % 'text' end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a string value",
+           "'-25' % 'text'")
+
+error_like(function () return '3' ^ 'text' end,
+           "^[^:]+:%d+: attempt to perform arithmetic on a string value",
+           "'3' ^ 'text'")
+
+is('10' + '2', 12, "'10' + '2'")
+
+is('2' - '10', -8, "'2' - '10'")
+
+is('3.14' * '1', 3.14, "'3.14' * '1'")
+
+is('-7' / '0.5', -14, "'-7' / '0.5'")
+
+is('-25' % '3', 2, "'-25' % '3'")
+
+is('3' ^ '3', 27, "'3' ^ '3'")
+
+is('1' .. 'end', '1end', "'1' .. 'end'")
+
+is('1' .. 2, '12', "'1' .. 2")
+
+error_like(function () return '1' .. true end,
+           "^[^:]+:%d+: attempt to concatenate a boolean value",
+           "'1' .. true")
+
+is('1.0' == '1', false, "'1.0' == '1'")
+
+is('1' ~= '2', true, "'1' ~= '2'")
+
+is('1' == true, false, "'1' == true")
+
+is('1' ~= nil, true, "'1' ~= nil")
+
+is('1' == 1, false, "'1' == 1")
+
+is('1' ~= 1, true, "'1' ~= 1")
+
+is('1' < '0', false, "'1' < '0'")
+
+is('1' <= '0', false, "'1' <= '0'")
+
+is('1' > '0', true, "'1' > '0'")
+
+is('1' >= '0', true, "'1' >= '0'")
+
+error_like(function () return '1' < false end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "'1' < false")
+
+error_like(function () return '1' <= nil end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "'1' <= nil")
+
+error_like(function () return '1' > true end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "'1' > true")
+
+error_like(function () return '1' >= {} end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "'1' >= {}")
+
+error_like(function () return '1' < 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "'1' < 0")
+
+error_like(function () return '1' <= 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "'1' <= 0")
+
+error_like(function () return '1' > 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "'1' > 0")
+
+error_like(function () return '1' > 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "'1' >== 0")
+
+a = 'text'
+is(a[1], nil, "index")
+
+error_like(function () a = 'text'; a[1] = 1; end,
+           "^[^:]+:%d+: attempt to index",
+           "index")
+
+-- Local Variables:
+--   mode: lua
+--   lua-indent-level: 4
+--   fill-column: 100
+-- End:
+-- vim: ft=lua expandtab shiftwidth=4:

+ 125 - 0
src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/106-table.t

@@ -0,0 +1,125 @@
+#! /usr/bin/lua
+--
+-- lua-TestMore : <http://fperrad.github.com/lua-TestMore/>
+--
+-- Copyright (C) 2009-2011, Perrad Francois
+--
+-- This code is licensed under the terms of the MIT/X11 license,
+-- like Lua itself.
+--
+
+--[[
+
+=head1 Lua table & coercion
+
+=head2 Synopsis
+
+    % prove 106-table.t
+
+=head2 Description
+
+=cut
+
+--]]
+
+require 'Test.More'
+
+plan(28)
+
+error_like(function () return -{} end,
+           "^[^:]+:%d+: attempt to perform arithmetic on",
+           "-{}")
+
+is(# {}, 0, "#{}")
+is(# {4,5,6}, 3)
+
+is(not {}, false, "not {}")
+
+error_like(function () return {} + 10 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on",
+           "{} + 10")
+
+error_like(function () return {} - 2 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on",
+           "{} - 2")
+
+error_like(function () return {} * 3.14 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on",
+           "{} * 3.14")
+
+error_like(function () return {} / 7 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on",
+           "{} / 7")
+
+error_like(function () return {} % 4 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on",
+           "{} % 4")
+
+error_like(function () return {} ^ 3 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on",
+           "{} ^ 3")
+
+error_like(function () return {} .. 'end' end,
+           "^[^:]+:%d+: attempt to concatenate",
+           "{} .. 'end'")
+
+is({} == {}, false, "{} == {}")
+
+t1 = {}
+t2 = {}
+is(t1 == t1, true, "t1 == t1")
+is(t1 == t2, false, "t1 == t2")
+is(t1 ~= t2, true, "t1 ~= t2")
+
+is({} == 1, false, "{} == 1")
+
+is({} ~= 1, true, "{} ~= 1")
+
+error_like(function () return t1 < t2 end,
+           "^[^:]+:%d+: attempt to compare two table values",
+           "t1 < t2")
+
+error_like(function () return t1 <= t2 end,
+           "^[^:]+:%d+: attempt to compare two table values",
+           "t1 <= t2")
+
+error_like(function () return t1 > t2 end,
+           "^[^:]+:%d+: attempt to compare two table values",
+           "t1 > t2")
+
+error_like(function () return t1 >= t2 end,
+           "^[^:]+:%d+: attempt to compare two table values",
+           "t1 >= t2")
+
+error_like(function () return {} < 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "{} < 0")
+
+error_like(function () return {} <= 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "{} <= 0")
+
+error_like(function () return {} > 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "{} > 0")
+
+error_like(function () return {} >= 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "{} >= 0")
+
+t = {}
+is( t[1], nil, "index" )
+t[1] = 42
+is( t[1], 42, "index" )
+
+error_like(function () t = {}; t[nil] = 42 end,
+           "^[^:]+:%d+: table index is nil",
+           "table index is nil")
+
+
+-- Local Variables:
+--   mode: lua
+--   lua-indent-level: 4
+--   fill-column: 100
+-- End:
+-- vim: ft=lua expandtab shiftwidth=4:

+ 128 - 0
src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/107-thread.t

@@ -0,0 +1,128 @@
+#! /usr/bin/lua
+--
+-- lua-TestMore : <http://fperrad.github.com/lua-TestMore/>
+--
+-- Copyright (C) 2009-2011, Perrad Francois
+--
+-- This code is licensed under the terms of the MIT/X11 license,
+-- like Lua itself.
+--
+
+--[[
+
+=head1 Lua thread & coercion
+
+=head2 Synopsis
+
+    % prove 107-thread.t
+
+=head2 Description
+
+=cut
+
+--]]
+
+require 'Test.More'
+
+plan(25)
+
+co = coroutine.create(function () return 1 end)
+
+error_like(function () return -co end,
+           "^[^:]+:%d+: attempt to perform arithmetic on",
+           "-co")
+
+error_like(function () return #co end,
+           "^[^:]+:%d+: attempt to get length of",
+           "#co")
+
+is(not co, false, "not co")
+
+error_like(function () return co + 10 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on",
+           "co + 10")
+
+error_like(function () return co - 2 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on",
+           "co - 2")
+
+error_like(function () return co * 3.14 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on",
+           "co * 3.14")
+
+error_like(function () return co / 7 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on",
+           "co / 7")
+
+error_like(function () return co % 4 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on",
+           "co % 4")
+
+error_like(function () return co ^ 3 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on",
+           "co ^ 3")
+
+error_like(function () return co .. 'end' end,
+           "^[^:]+:%d+: attempt to concatenate",
+           "co .. 'end'")
+
+is(co == co, true, "co == co")
+
+co1 = coroutine.create(function () return 1 end)
+co2 = coroutine.create(function () return 2 end)
+is(co1 ~= co2, true, "co1 ~= co2")
+
+is(co == 1, false, "co == 1")
+
+is(co ~= 1, true, "co ~= 1")
+
+error_like(function () return co1 < co2 end,
+           "^[^:]+:%d+: attempt to compare two thread values",
+           "co1 < co2")
+
+error_like(function () return co1 <= co2 end,
+           "^[^:]+:%d+: attempt to compare two thread values",
+           "co1 <= co2")
+
+error_like(function () return co1 > co2 end,
+           "^[^:]+:%d+: attempt to compare two thread values",
+           "co1 > co2")
+
+error_like(function () return co1 >= co2 end,
+           "^[^:]+:%d+: attempt to compare two thread values",
+           "co1 >= co2")
+
+error_like(function () return co < 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "co < 0")
+
+error_like(function () return co <= 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "co <= 0")
+
+error_like(function () return co > 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "co > 0")
+
+error_like(function () return co > 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "co >= 0")
+
+error_like(function () a = co[1] end,
+           "^[^:]+:%d+: attempt to index",
+           "index")
+
+error_like(function () co[1] = 1 end,
+           "^[^:]+:%d+: attempt to index",
+           "index")
+
+t = {}
+t[co] = true
+ok(t[co])
+
+-- Local Variables:
+--   mode: lua
+--   lua-indent-level: 4
+--   fill-column: 100
+-- End:
+-- vim: ft=lua expandtab shiftwidth=4:

+ 125 - 0
src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/108-userdata.t

@@ -0,0 +1,125 @@
+#! /usr/bin/lua
+--
+-- lua-TestMore : <http://fperrad.github.com/lua-TestMore/>
+--
+-- Copyright (C) 2009-2011, Perrad Francois
+--
+-- This code is licensed under the terms of the MIT/X11 license,
+-- like Lua itself.
+--
+
+--[[
+
+=head1 Lua userdata & coercion
+
+=head2 Synopsis
+
+    % prove 108-userdata.t
+
+=head2 Description
+
+=cut
+
+--]]
+
+require 'Test.More'
+
+plan(25)
+
+u = io.stdin
+
+error_like(function () return -u end,
+           "^[^:]+:%d+: attempt to perform arithmetic on",
+           "-u")
+
+error_like(function () return #u end,
+           "^[^:]+:%d+: attempt to get length of",
+           "#u")
+
+is(not u, false, "not u")
+
+error_like(function () return u + 10 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on",
+           "u + 10")
+
+error_like(function () return u - 2 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on",
+           "u - 2")
+
+error_like(function () return u * 3.14 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on",
+           "u * 3.14")
+
+error_like(function () return u / 7 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on",
+           "u / 7")
+
+error_like(function () return u % 4 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on",
+           "u % 4")
+
+error_like(function () return u ^ 3 end,
+           "^[^:]+:%d+: attempt to perform arithmetic on",
+           "u ^ 3")
+
+error_like(function () return u .. 'end' end,
+           "^[^:]+:%d+: attempt to concatenate",
+           "u .. 'end'")
+
+is(u == u, true, "u == u")
+
+v = io.stdout
+is(u ~= v, true, "u ~= v")
+
+is(u == 1, false, "u == 1")
+
+is(u ~= 1, true, "u ~= 1")
+
+error_like(function () return u < v end,
+           "^[^:]+:%d+: attempt to compare two userdata values",
+           "u < v")
+
+error_like(function () return u <= v end,
+           "^[^:]+:%d+: attempt to compare two userdata values",
+           "u <= v")
+
+error_like(function () return u > v end,
+           "^[^:]+:%d+: attempt to compare two userdata values",
+           "u > v")
+
+error_like(function () return u >= v end,
+           "^[^:]+:%d+: attempt to compare two userdata values",
+           "u >= v")
+
+error_like(function () return u < 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "u < 0")
+
+error_like(function () return u <= 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "u <= 0")
+
+error_like(function () return u > 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "u > 0")
+
+error_like(function () return u > 0 end,
+           "^[^:]+:%d+: attempt to compare %w+ with %w+",
+           "u >= 0")
+
+is(u[1], nil, "index")
+
+error_like(function () u[1] = 1 end,
+           "^[^:]+:%d+: attempt to index",
+           "index")
+
+t = {}
+t[u] = true
+ok(t[u])
+
+-- Local Variables:
+--   mode: lua
+--   lua-indent-level: 4
+--   fill-column: 100
+-- End:
+-- vim: ft=lua expandtab shiftwidth=4:

+ 104 - 0
src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/200-examples.t

@@ -0,0 +1,104 @@
+#! /usr/bin/lua
+--
+-- lua-TestMore : <http://fperrad.github.com/lua-TestMore/>
+--
+-- Copyright (C) 2009-2011, Perrad Francois
+--
+-- This code is licensed under the terms of the MIT/X11 license,
+-- like Lua itself.
+--
+
+--[[
+
+=head1 some Lua code examples
+
+=head2 Synopsis
+
+    % prove 200-examples.t
+
+=head2 Description
+
+First tests in order to check infrastructure.
+
+=cut
+
+--]]
+
+require 'Test.More'
+
+plan(5)
+
+function factorial (n)
+    if n == 0 then
+        return 1
+    else
+        return n * factorial(n-1)
+    end
+end
+is(factorial(7), 5040, "factorial (recursive)")
+
+local function local_factorial (n)
+    if n == 0 then
+        return 1
+    else
+        return n * local_factorial(n-1)
+    end
+end
+is(local_factorial(7), 5040, "factorial (recursive)")
+
+function loop_factorial (n)
+    local a = 1
+    for i = 1, n, 1 do
+        a = a*i
+    end
+    return a
+end
+is(loop_factorial(7), 5040, "factorial (loop)")
+
+function iter_factorial (n)
+    local function iter (product, counter)
+        if counter > n then
+            return product
+        else
+            return iter(counter*product, counter+1)
+        end
+    end
+    return iter(1, 1)
+end
+is(iter_factorial(7), 5040, "factorial (iter)")
+
+--[[
+
+  Knuth's "man or boy" test.
+  See http://en.wikipedia.org/wiki/Man_or_boy_test
+
+]]
+
+local function A (k, x1, x2, x3, x4, x5)
+    local function B ()
+        k = k - 1
+        return A(k, B, x1, x2, x3, x4)
+    end
+    if k <= 0 then
+        return x4() + x5()
+    else
+        return B()
+    end
+end
+
+is(A(10,
+        function () return 1 end,
+        function () return -1 end,
+        function () return -1 end,
+        function () return 1 end,
+        function () return 0 end),
+   -67,
+   "man or boy"
+)
+
+-- Local Variables:
+--   mode: lua
+--   lua-indent-level: 4
+--   fill-column: 100
+-- End:
+-- vim: ft=lua expandtab shiftwidth=4:

+ 125 - 0
src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/201-assign.t

@@ -0,0 +1,125 @@
+#! /usr/bin/lua
+--
+-- lua-TestMore : <http://fperrad.github.com/lua-TestMore/>
+--
+-- Copyright (C) 2009-2013, Perrad Francois
+--
+-- This code is licensed under the terms of the MIT/X11 license,
+-- like Lua itself.
+--
+
+--[[
+
+=head1 Lua assignment
+
+=head2 Synopsis
+
+    % prove 201-assign.t
+
+=head2 Description
+
+See "Lua 5.2 Reference Manual", section 3.3.3 "Assignment",
+L<http://www.lua.org/manual/5.2/manual.html#3.3.3>.
+
+See "Programming in Lua", section 4.1 "Assignment".
+
+=cut
+
+--]]
+
+require 'Test.More'
+
+plan(38)
+
+is(b, nil, "global variable")
+b = 10
+is(b, 10)
+if jit then
+    skip("LuaJIT intentional. _ENV.", 3)
+else
+    is(_ENV.b, 10, "_ENV")
+    is(_G, _ENV, "_G")
+    error_like([[ _ENV = nil; b = 20 ]],
+               "^[^:]+:%d+: attempt to index a nil value")
+end
+b = nil
+is(b, nil)
+
+a = {}
+i = 3
+i, a[i] = i+1, 20
+-- this behavior is undefined
+-- see http://lua-users.org/lists/lua-l/2006-06/msg00378.html
+-- is(i, 4, "check eval")
+-- is(a[3], 20)
+
+x = 1.
+y = 2.
+x, y = y, x -- swap
+is(x, 2, "check swap")
+is(y, 1)
+
+a, b, c = 0, 1
+is(a, 0, "check padding")
+is(b, 1)
+is(c, nil)
+a, b = a+1, b+1, a+b
+is(a, 1)
+is(b, 2)
+a, b, c = 0
+is(a, 0)
+is(b, nil)
+is(c, nil)
+
+function f() return 1, 2 end
+a, b, c, d = f()
+is(a, 1, "adjust with function")
+is(b, 2)
+is(c, nil)
+is(d, nil)
+
+function f() print('# f') end
+a = 2
+a, b, c = f(), 3
+is(a, nil, "padding with function")
+is(b, 3)
+is(c, nil)
+
+local my_i = 1
+is(my_i, 1, "local variable")
+local my_i = 2
+is(my_i, 2)
+
+local i = 1
+local j = i
+is(i, 1, "local variable")
+is(j, 1)
+j = 2
+is(i, 1)
+is(j, 2)
+
+local function f(x) return 2*x end
+is(f(2), 4, "param & result of function")
+a = 2
+a = f(a)
+is(a, 4)
+local b = 2
+b = f(b)
+is(b, 4)
+
+local n1 = 1
+local n2 = 2
+local n3 = 3
+local n4 = 4
+n1,n2,n3,n4 = n4,n3,n2,n1
+is(n1, 4, "assignment list swap values")
+is(n2, 3)
+is(n3, 2)
+is(n4, 1)
+
+-- Local Variables:
+--   mode: lua
+--   lua-indent-level: 4
+--   fill-column: 100
+-- End:
+-- vim: ft=lua expandtab shiftwidth=4:

+ 111 - 0
src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/202-expr.t

@@ -0,0 +1,111 @@
+#! /usr/bin/lua
+--
+-- lua-TestMore : <http://fperrad.github.com/lua-TestMore/>
+--
+-- Copyright (C) 2009-2010, Perrad Francois
+--
+-- This code is licensed under the terms of the MIT/X11 license,
+-- like Lua itself.
+--
+
+--[[
+
+=head1 Lua expression
+
+=head2 Synopsis
+
+    % prove 202-expr.t
+
+=head2 Description
+
+See "Lua 5.2 Reference Manual", section 3.4 "Expressions",
+L<http://www.lua.org/manual/5.2/manual.html#3.4>.
+
+See "Programming in Lua", section 3 "Expressions".
+
+=cut
+
+--]]
+
+require 'Test.More'
+
+plan(39)
+
+x = math.pi
+is(x - x%0.01, 3.14, "modulo")
+
+a = {}; a.x = 1; a.y = 0;
+b = {}; b.x = 1; b.y = 0;
+c = a
+is(a == c, true, "relational op (by reference)")
+is(a ~= b, true)
+
+is('0' == 0, false, "relational op")
+is(2 < 15, true)
+is('2' < '15', false)
+
+error_like(function () return 2 < '15' end,
+           "compare",
+           "relational op")
+
+error_like(function () return '2' < 15 end,
+           "compare",
+           "relational op")
+
+is(4 and 5, 5, "logical op")
+is(nil and 13, nil)
+is(false and 13, false)
+is(4 or 5, 4)
+is(false or 5, 5)
+is(false or 'text', 'text')
+
+is(10 or 20, 10, "logical op")
+is(10 or error(), 10)
+is(nil or 'a', 'a')
+is(nil and 10, nil)
+is(false and error(), false)
+is(false and nil, false)
+is(false or nil, nil)
+is(10 and 20, 20)
+
+is(not nil, true, "logical not")
+is(not false, true)
+is(not 0, false)
+is(not not nil, false)
+is(not 'text', false)
+a = {}
+is(not a, false)
+
+is("Hello " .. "World", "Hello World", "concatenation")
+is(0 .. 1, '01')
+a = "Hello"
+is(a .. " World", "Hello World")
+is(a, "Hello")
+
+is('10' + 1, 11, "coercion")
+is('-5.3' * '2', -10.6)
+is(10 .. 20, '1020')
+is(tostring(10), '10')
+is(10 .. '', '10')
+
+error_like(function () return 'hello' + 1 end,
+           "perform arithmetic",
+           "no coercion")
+
+error_like(function ()
+                local function first() return 1 end
+                local function limit() return end
+                local function step()  return 2 end
+                for i = first(), limit(), step() do
+                    print(i)
+                end
+           end,
+           "^[^:]+:%d+: 'for' limit must be a number",
+           "for tonumber")
+
+-- Local Variables:
+--   mode: lua
+--   lua-indent-level: 4
+--   fill-column: 100
+-- End:
+-- vim: ft=lua expandtab shiftwidth=4:

+ 122 - 0
src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/203-lexico.t

@@ -0,0 +1,122 @@
+#! /usr/bin/lua
+--
+-- lua-TestMore : <http://fperrad.github.com/lua-TestMore/>
+--
+-- Copyright (C) 2010, Perrad Francois
+--
+-- This code is licensed under the terms of the MIT/X11 license,
+-- like Lua itself.
+--
+
+--[[
+
+=head1 Lua Lexicography
+
+=head2 Synopsis
+
+    % prove 203-lexico.t
+
+=head2 Description
+
+See "Lua 5.2 Reference Manual", section 3.1 "Lexical Conventions",
+L<http://www.lua.org/manual/5.2/manual.html#3.1>.
+
+=cut
+
+--]]
+
+require 'Test.More'
+
+plan(40)
+
+is("\65", "A")
+is("\065", "A")
+is("\x41", "A")
+is("\x3d", "=")
+is("\x3D", "=")
+
+is(string.byte("\a"), 7)
+is(string.byte("\b"), 8)
+is(string.byte("\f"), 12)
+is(string.byte("\n"), 10)
+is(string.byte("\r"), 13)
+is(string.byte("\t"), 9)
+is(string.byte("\v"), 11)
+is(string.byte("\\"), 92)
+
+is(string.len("A\0B"), 3)
+
+f, msg = load [[a = "A\300"]]
+like(msg, "^[^:]+:%d+: .- escape .- near")
+
+f, msg = load [[a = "A\xyz"]]
+like(msg, "^[^:]+:%d+: .- near")
+
+f, msg = load [[a = "A\Z"]]
+like(msg, "^[^:]+:%d+: .- escape .- near")
+
+f, msg = load [[a = " unfinished string ]]
+like(msg, "^[^:]+:%d+: unfinished string near")
+
+f, msg = load [[a = " unfinished string
+]]
+like(msg, "^[^:]+:%d+: unfinished string near")
+
+f, msg = load [[a = " unfinished string \
+]]
+like(msg, "^[^:]+:%d+: unfinished string near")
+
+f, msg = load [[a = " unfinished string \]]
+like(msg, "^[^:]+:%d+: unfinished string near")
+
+f, msg = load "a = [[ unfinished long string "
+like(msg, "^[^:]+:%d+: unfinished long string near")
+
+f, msg = load "a = [== invalid long string delimiter "
+like(msg, "^[^:]+:%d+: invalid long string delimiter near")
+
+a = 'alo\n123"'
+is('alo\n123"', a)
+is("alo\n123\"", a)
+is('\97lo\10\04923"', a)
+is([[alo
+123"]], a)
+is([==[
+alo
+123"]==], a)
+is("alo\n\z
+123\"", a)
+
+f, msg = load [[a = " escape \z unauthorized
+new line" ]]
+like(msg, "^[^:]+:%d+: unfinished string near")
+
+is(3.0, 3)
+is(314.16e-2, 3.1416)
+is(0.31416E1, 3.1416)
+is(0xff, 255)
+is(0x56, 86)
+is(0x0.1E, 0x1E / 0x100)        -- 0.1171875
+is(0xA23p-4, 0xA23 / (2^4))     -- 162.1875
+is(0X1.921FB54442D18P+1, (1 + 0x921FB54442D18/0x10000000000000) * 2)
+
+f, msg = load [[a = 12e34e56]]
+like(msg, "^[^:]+:%d+: malformed number near")
+
+--[===[
+--[[
+--[=[
+    nested long comments
+--]=]
+--]]
+--]===]
+
+f, msg = load "  --[[ unfinished long comment "
+like(msg, "^[^:]+:%d+: unfinished long comment near")
+
+-- Local Variables:
+--   mode: lua
+--   lua-indent-level: 4
+--   fill-column: 100
+-- End:
+-- vim: ft=lua expandtab shiftwidth=4:

+ 106 - 0
src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/204-grammar.t

@@ -0,0 +1,106 @@
+#! /usr/bin/lua
+--
+-- lua-TestMore : <http://fperrad.github.com/lua-TestMore/>
+--
+-- Copyright (C) 2010-2013, Perrad Francois
+--
+-- This code is licensed under the terms of the MIT/X11 license,
+-- like Lua itself.
+--
+
+--[[
+
+=head1 Lua Grammar
+
+=head2 Synopsis
+
+    % prove 204-grammar.t
+
+=head2 Description
+
+See "Lua 5.2 Reference Manual", section 9 "The Complete Syntax of Lua",
+L<http://www.lua.org/manual/5.2/manual.html#9>.
+
+=cut
+
+--]]
+
+require 'Test.More'
+
+plan(6)
+
+--[[ empty statement ]]
+f, msg = load [[; a = 1]]
+type_ok(f, 'function', "empty statement")
+
+--[[ orphan break ]]
+f, msg = load [[
+function f()
+    print "before"
+    do
+        print "inner"
+        break
+    end
+    print "after"
+end
+]]
+if jit then
+    like(msg, "^[^:]+:%d+: no loop to break", "orphan break")
+else
+    like(msg, "^[^:]+:%d+: <break> at line 5 not inside a loop", "orphan break")
+end
+
+--[[ break anywhere ]]
+lives_ok( [[
+function f()
+    print "before"
+    while true do
+        print "inner"
+        break
+        print "break"
+    end
+    print "after"
+end
+]], "break anywhere")
+
+--[[ goto ]]
+f, msg = load [[
+::label::
+goto unknown
+]]
+if jit then
+    like(msg, ":%d+: undefined label 'unknown'", "unknown goto")
+else
+    like(msg, ":%d+: no visible label 'unknown' for <goto> at line %d+", "unknown goto")
+end
+
+f, msg = load [[
+::label::
+goto label
+::label::
+]]
+if jit then
+    like(msg, ":%d+: duplicate label 'label'", "duplicate label")
+else
+    like(msg, ":%d+: label 'label' already defined on line %d+", "duplicate label")
+end
+
+f, msg = load [[
+::e::
+goto f
+local x
+::f::
+goto e
+]]
+if jit then
+    like(msg, ":%d+: <goto f> jumps into the scope of local 'x'", "bad goto")
+else
+    like(msg, ":%d+: <goto f> at line %d+ jumps into the scope of local 'x'", "bad goto")
+end
+
+-- Local Variables:
+--   mode: lua
+--   lua-indent-level: 4
+--   fill-column: 100
+-- End:
+-- vim: ft=lua expandtab shiftwidth=4:

+ 83 - 0
src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/211-scope.t

@@ -0,0 +1,83 @@
+#! /usr/bin/lua
+--
+-- lua-TestMore : <http://fperrad.github.com/lua-TestMore/>
+--
+-- Copyright (C) 2009-2010, Perrad Francois
+--
+-- This code is licensed under the terms of the MIT/X11 license,
+-- like Lua itself.
+--
+
+--[[
+
+=head1 Lua scope
+
+=head2 Synopsis
+
+    % prove 211-scope.t
+
+=head2 Description
+
+See "Lua 5.2 Reference Manual", section 3.5 "Visibility Rules",
+L<http://www.lua.org/manual/5.2/manual.html#3.5>.
+
+See "Programming in Lua", section 4.2 "Local Variables and Blocks".
+
+=cut
+
+--]]
+
+require 'Test.More'
+
+plan(10)
+
+--[[ scope ]]
+x = 10
+do
+    local x = x
+    is(x, 10, "scope")
+    x = x + 1
+    do
+        local x = x + 1
+        is(x, 12)
+    end
+    is(x, 11)
+end
+is(x, 10)
+
+--[[ scope ]]
+x = 10
+local i = 1
+
+while i<=x do
+    local x = i*2
+--    print(x)
+    i = i + 1
+end
+
+if i > 20 then
+    local x
+    x = 20
+    nok("scope")
+else
+    is(x, 10, "scope")
+end
+
+is(x, 10)
+
+--[[ scope ]]
+local a, b = 1, 10
+if a < b then
+    is(a, 1, "scope")
+    local a
+    is(a, nil)
+end
+is(a, 1)
+is(b, 10)
+
+-- Local Variables:
+--   mode: lua
+--   lua-indent-level: 4
+--   fill-column: 100
+-- End:
+-- vim: ft=lua expandtab shiftwidth=4:

+ 268 - 0
src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/212-function.t

@@ -0,0 +1,268 @@
+#! /usr/bin/lua
+--
+-- lua-TestMore : <http://fperrad.github.com/lua-TestMore/>
+--
+-- Copyright (C) 2009-2010, Perrad Francois
+--
+-- This code is licensed under the terms of the MIT/X11 license,
+-- like Lua itself.
+--
+
+--[[
+
+=head1 Lua functions
+
+=head2 Synopsis
+
+    % prove 212-function.t
+
+=head2 Description
+
+See "Lua 5.2 Reference Manual", section 3.4.10 "Function Definitions",
+L<http://www.lua.org/manual/5.2/manual.html#3.4.10>.
+
+See "Programming in Lua", section 5 "Functions".
+
+=cut
+
+--]]
+
+require 'Test.More'
+
+plan(63)
+
+--[[ add ]]
+function add (a)
+    local sum = 0
+    for i,v in ipairs(a) do
+        sum = sum + v
+    end
+    return sum
+end
+
+t = { 10, 20, 30, 40 }
+is(add(t), 100, "add")
+
+--[[ f ]]
+function f(a, b) return a or b end
+
+is(f(3), 3, "f")
+is(f(3, 4), 3)
+is(f(3, 4, 5), 3)
+
+--[[ incCount ]]
+count = 0
+
+function incCount (n)
+    n = n or 1
+    count = count + n
+end
+
+is(count, 0, "inCount")
+incCount()
+is(count, 1)
+incCount(2)
+is(count, 3)
+incCount(1)
+is(count, 4)
+
+--[[ maximum ]]
+function maximum (a)
+    local mi = 1                -- maximum index
+    local m = a[mi]             -- maximum value
+    for i,val in ipairs(a) do
+        if val > m then
+            mi = i
+            m = val
+        end
+    end
+    return m, mi
+end
+
+local m, mi = maximum({8,10,23,12,5})
+is(m, 23, "maximum")
+is(mi, 3)
+
+--[[ call by value ]]
+function f (n)
+    n = n - 1
+    return n
+end
+
+a = 12
+is(a, 12, "call by value")
+b = f(a)
+is(b, 11)
+is(a, 12)
+c = f(12)
+is(c, 11)
+is(a, 12)
+
+--[[ call by ref ]]
+function f (t)
+    t[#t+1] = 'end'
+    return t
+end
+
+a = { 'a', 'b', 'c' }
+is(table.concat(a, ','), 'a,b,c', "call by ref")
+b = f(a)
+is(table.concat(b, ','), 'a,b,c,end')
+is(table.concat(a, ','), 'a,b,c,end')
+
+--[[ var args ]]
+local function g(a, b, ...)
+    local arg = {...}
+    is(a, 3, "vararg")
+    is(b, nil)
+    is(#arg, 0)
+    is(arg[1], nil)
+end
+g(3)
+
+local function g(a, b, ...)
+    local arg = {...}
+    is(a, 3)
+    is(b, 4)
+    is(#arg, 0)
+    is(arg[1], nil)
+end
+g(3, 4)
+
+local function g(a, b, ...)
+    local arg = {...}
+    is(a, 3)
+    is(b, 4)
+    is(#arg, 2)
+    is(arg[1], 5)
+    is(arg[2], 8)
+end
+g(3, 4, 5, 8)
+
+--[[ var args ]]
+local function g(a, b, ...)
+    local c, d, e = ...
+    is(a, 3, "var args")
+    is(b, nil)
+    is(c, nil)
+    is(d, nil)
+    is(e, nil)
+end
+g(3)
+
+local function g(a, b, ...)
+    local c, d, e = ...
+    is(a, 3)
+    is(b, 4)
+    is(c, nil)
+    is(d, nil)
+    is(e, nil)
+end
+g(3, 4)
+
+local function g(a, b, ...)
+    local c, d, e = ...
+    is(a, 3)
+    is(b, 4)
+    is(c, 5)
+    is(d, 8)
+    is(e, nil)
+end
+
+--[[ var args ]]
+local function g(a, b, ...)
+    is(#{a, b, ...}, 1, "varargs")
+end
+g(3)
+
+local function g(a, b, ...)
+    is(#{a, b, ...}, 2)
+end
+g(3, 4)
+
+local function g(a, b, ...)
+    is(#{a, b, ...}, 4)
+end
+g(3, 4, 5, 8)
+
+--[[ var args ]]
+function f() return 1, 2 end
+function g() return 'a', f() end
+function h() return f(), 'b' end
+function k() return 'c', (f()) end
+
+x, y = f()
+is(x, 1, "var args")
+is(y, 2)
+x, y, z = g()
+is(x, 'a')
+is(y, 1)
+is(z, 2)
+x, y = h()
+is(x, 1)
+is(y, 'b')
+x, y, z = k()
+is(x, 'c')
+is(y, 1)
+is(z, nil)
+
+
+--[[ invalid var args ]]
+f, msg = load [[
+function f ()
+    print(...)
+end
+]]
+like(msg, "^[^:]+:%d+: cannot use '...' outside a vararg function", "invalid var args")
+
+--[[ tail call ]]
+output = {}
+local function foo (n)
+    output[#output+1] = n
+    if n > 0 then
+        return foo(n -1)
+    end
+    return 'end', 0
+end
+
+eq_array({foo(3)}, {'end', 0}, "tail call")
+eq_array(output, {3, 2, 1, 0})
+
+--[[ no tail call ]]
+output = {}
+local function foo (n)
+    output[#output+1] = n
+    if n > 0 then
+        return (foo(n -1))
+    end
+    return 'end', 0
+end
+
+is(foo(3), 'end', "no tail call")
+eq_array(output, {3, 2, 1, 0})
+
+--[[ no tail call ]]
+output = {}
+local function foo (n)
+    output[#output+1] = n
+    if n > 0 then
+        foo(n -1)
+    end
+end
+
+is(foo(3), nil, "no tail call")
+eq_array(output, {3, 2, 1, 0})
+
+--[[ sub name ]]
+local function f () return 1 end
+is(f(), 1, "sub name")
+
+local function f () return 2 end
+is(f(), 2)
+
+-- Local Variables:
+--   mode: lua
+--   lua-indent-level: 4
+--   fill-column: 100
+-- End:
+-- vim: ft=lua expandtab shiftwidth=4:

+ 98 - 0
src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/213-closure.t

@@ -0,0 +1,98 @@
+#! /usr/bin/lua
+--
+-- lua-TestMore : <http://fperrad.github.com/lua-TestMore/>
+--
+-- Copyright (C) 2009-2010, Perrad Francois
+--
+-- This code is licensed under the terms of the MIT/X11 license,
+-- like Lua itself.
+--
+
+--[[
+
+=head1 Lua closures
+
+=head2 Synopsis
+
+    % prove 213-closure.t
+
+=head2 Description
+
+See "Lua 5.2 Reference Manual", section 3.5 "Visibility Rules",
+L<http://www.lua.org/manual/5.2/manual.html#3.5>.
+
+See "Programming in Lua", section 6.1 "Closures".
+
+=cut
+
+--]]
+
+require 'Test.More'
+
+plan(15)
+
+--[[ inc ]]
+local counter = 0
+
+function inc (x)
+    counter = counter + x
+    return counter
+end
+
+is(inc(1), 1, "inc")
+is(inc(2), 3)
+
+--[[ newCounter ]]
+function newCounter ()
+    local i = 0
+    return function ()  -- anonymous function
+               i = i + 1
+               return i
+           end
+end
+
+c1 = newCounter()
+is(c1(), 1, "newCounter")
+is(c1(), 2)
+
+c2 = newCounter()
+is(c2(), 1)
+is(c1(), 3)
+is(c2(), 2)
+
+--[[
+The loop creates ten closures (that is, ten instances of the anonymous
+function). Each of these closures uses a different y variable, while all
+of them share the same x.
+]]
+a = {}
+local x = 20
+for i=1,10 do
+    local y = 0
+    a[i] = function () y=y+1; return x+y end
+end
+
+is(a[1](), 21, "ten closures")
+is(a[1](), 22)
+is(a[2](), 21)
+
+
+--[[ add ]]
+function add(x)
+    return function (y) return (x + y) end
+end
+
+f = add(2)
+type_ok(f, 'function', "add")
+is(f(10), 12)
+g = add(5)
+is(g(1), 6)
+is(g(10), 15)
+is(f(1), 3)
+
+-- Local Variables:
+--   mode: lua
+--   lua-indent-level: 4
+--   fill-column: 100
+-- End:
+-- vim: ft=lua expandtab shiftwidth=4:

+ 193 - 0
src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/214-coroutine.t

@@ -0,0 +1,193 @@
+#! /usr/bin/lua
+--
+-- lua-TestMore : <http://fperrad.github.com/lua-TestMore/>
+--
+-- Copyright (C) 2009-2011, Perrad Francois
+--
+-- This code is licensed under the terms of the MIT/X11 license,
+-- like Lua itself.
+--
+
+--[[
+
+=head1 Lua coroutines
+
+=head2 Synopsis
+
+    % prove 214-coroutine.t
+
+=head2 Description
+
+See "Lua 5.2 Reference Manual", section 2.6 "Coroutines",
+L<http://www.lua.org/manual/5.2/manual.html#2.6>.
+
+See "Programming in Lua", section 9 "Coroutines".
+
+=cut
+
+--]]
+
+require 'Test.More'
+
+plan(30)
+
+--[[ ]]
+output = {}
+
+function foo1 (a)
+    output[#output+1] = "foo " .. a
+    return coroutine.yield(2*a)
+end
+
+co = coroutine.create(function (a,b)
+        output[#output+1] = "co-body " .. a .." " .. b
+        local r = foo1(a+1)
+        output[#output+1] = "co-body " .. r
+        local r, s = coroutine.yield(a+b, a-b)
+        output[#output+1] = "co-body " .. r .. " " .. s
+        return b, 'end'
+    end)
+
+eq_array({coroutine.resume(co, 1, 10)}, {true, 4}, "foo1")
+eq_array({coroutine.resume(co, 'r')}, {true, 11, -9})
+eq_array({coroutine.resume(co, "x", "y")}, {true, 10, 'end'})
+eq_array({coroutine.resume(co, "x", "y")}, {false, "cannot resume dead coroutine"})
+eq_array(output, {
+    'co-body 1 10',
+    'foo 2',
+    'co-body r',
+    'co-body x y',
+})
+
+--[[ ]]
+co = coroutine.create(function ()
+        output = 'hi'
+    end)
+like(co, '^thread: 0?[Xx]?%x+$', "basics")
+
+is(coroutine.status(co), 'suspended')
+output = ''
+coroutine.resume(co)
+is(output, 'hi')
+is(coroutine.status(co), 'dead')
+
+error_like(function () coroutine.create(true) end,
+           "^[^:]+:%d+: bad argument #1 to 'create' %(function expected, got boolean%)")
+
+error_like(function () coroutine.resume(true) end,
+           "^[^:]+:%d+: bad argument #1 to 'resume' %(coroutine expected, got boolean%)")
+
+error_like(function () coroutine.status(true) end,
+           "^[^:]+:%d+: bad argument #1 to 'status' %(coroutine expected, got boolean%)")
+
+--[[ ]]
+output = {}
+co = coroutine.create(function ()
+        for i=1,10 do
+            output[#output+1] = i
+            coroutine.yield()
+        end
+    end)
+
+coroutine.resume(co)
+thr, ismain = coroutine.running(co)
+type_ok(thr, 'thread', "running")
+is(ismain, true, "running")
+is(coroutine.status(co), 'suspended', "basics")
+coroutine.resume(co)
+coroutine.resume(co)
+coroutine.resume(co)
+coroutine.resume(co)
+coroutine.resume(co)
+coroutine.resume(co)
+coroutine.resume(co)
+coroutine.resume(co)
+coroutine.resume(co)
+coroutine.resume(co)
+eq_array({coroutine.resume(co)}, {false, 'cannot resume dead coroutine'})
+eq_array(output, {1,2,3,4,5,6,7,8,9,10})
+
+--[[ ]]
+co = coroutine.create(function (a,b)
+        coroutine.yield(a + b, a - b)
+    end)
+
+eq_array({coroutine.resume(co, 20, 10)}, {true, 30, 10}, "basics")
+
+--[[ ]]
+co = coroutine.create(function ()
+        return 6, 7
+    end)
+
+eq_array({coroutine.resume(co)}, {true, 6, 7}, "basics")
+
+--[[ ]]
+co = coroutine.wrap(function(...)
+  return pcall(function(...)
+    return coroutine.yield(...)
+  end, ...)
+end)
+eq_array({co("Hello")}, {"Hello"})
+eq_array({co("World")}, {true, "World"})
+
+--[[ ]]
+co = coroutine.wrap(function(...)
+  function backtrace ()
+    return 'not a back trace'
+  end
+  return xpcall(function(...)
+    return coroutine.yield(...)
+  end, backtrace, ...)
+end)
+eq_array({co("Hello")}, {"Hello"})
+eq_array({co("World")}, {true, "World"})
+
+
+--[[ ]]
+local output = {}
+co = coroutine.wrap(function()
+  while true do
+    local t = setmetatable({}, {
+      __eq = function(...)
+        return coroutine.yield(...)
+      end}
+    )
+    local t2 = setmetatable({}, getmetatable(t))
+    output[#output+1] = t == t2
+  end
+end)
+co()
+co(true)
+co(false)
+eq_array(output, {true, false})
+
+--[[ ]]
+co = coroutine.wrap(print)
+type_ok(co, 'function')
+
+error_like(function () coroutine.wrap(true) end,
+           "^[^:]+:%d+: bad argument #1 to 'wrap' %(function expected, got boolean%)")
+
+co = coroutine.wrap(function () error"in coro" end)
+error_like(function () co() end,
+           "^[^:]+:%d+: in coro$")
+
+--[[ ]]
+co = coroutine.create(function ()
+        error "in coro"
+    end)
+r, msg = coroutine.resume(co)
+is(r, false)
+like(msg, "in coro$")
+
+--[[ ]]
+error_like(function () coroutine.yield() end,
+           "attempt to yield")
+
+
+-- Local Variables:
+--   mode: lua
+--   lua-indent-level: 4
+--   fill-column: 100
+-- End:
+-- vim: ft=lua expandtab shiftwidth=4:

+ 112 - 0
src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/221-table.t

@@ -0,0 +1,112 @@
+#! /usr/bin/lua
+--
+-- lua-TestMore : <http://fperrad.github.com/lua-TestMore/>
+--
+-- Copyright (C) 2009, Perrad Francois
+--
+-- This code is licensed under the terms of the MIT/X11 license,
+-- like Lua itself.
+--
+
+--[[
+
+=head1 Lua tables
+
+=head2 Synopsis
+
+    % prove 221-table.t
+
+=head2 Description
+
+See "Programming in Lua", section 2.5 "Tables".
+
+=cut
+
+--]]
+
+require 'Test.More'
+
+plan(25)
+
+--[[ ]]
+a = {}
+k = 'x'
+a[k] = 10
+a[20] = 'great'
+is(a['x'], 10)
+k = 20
+is(a[k], 'great')
+a['x'] = a ['x'] + 1
+is(a['x'], 11)
+
+--[[ ]]
+a = {}
+a['x'] = 10
+b = a
+is(b['x'], 10)
+b['x'] = 20
+is(a['x'], 20)
+a = nil
+b = nil
+
+--[[ ]]
+a = {}
+for i=1,1000 do a[i] = i*2 end
+is(a[9], 18)
+a['x'] = 10
+is(a['x'], 10)
+is(a['y'], nil)
+
+--[[ ]]
+a = {}
+x = 'y'
+a[x] = 10
+is(a[x], 10)
+is(a.x, nil)
+is(a.y, 10)
+
+--[[ ]]
+i = 10; j = '10'; k = '+10'
+a = {}
+a[i] = "one value"
+a[j] = "another value"
+a[k] = "yet another value"
+is(a[j], "another value")
+is(a[k], "yet another value")
+is(a[tonumber(j)], "one value")
+is(a[tonumber(k)], "one value")
+
+t = { {'a','b','c'}, 10 }
+is(t[2], 10)
+is(t[1][3], 'c')
+t[1][1] = 'A'
+is(table.concat(t[1],','), 'A,b,c')
+
+--[[ ]]
+local tt
+tt = { {'a','b','c'}, 10 }
+is(tt[2], 10)
+is(tt[1][3], 'c')
+tt[1][1] = 'A'
+is(table.concat(tt[1],','), 'A,b,c')
+
+--[[ ]]
+a = {}
+error_like(function () a() end,
+           "^[^:]+:%d+: attempt to call")
+
+--[[ ]]
+local tt
+tt = { {'a','b','c'}, 10 }
+is((tt)[2], 10)
+is((tt[1])[3], 'c');
+(tt)[1][2] = 'B'
+(tt[1])[3] = 'C'
+is(table.concat(tt[1],','), 'a,B,C')
+
+-- Local Variables:
+--   mode: lua
+--   lua-indent-level: 4
+--   fill-column: 100
+-- End:
+-- vim: ft=lua expandtab shiftwidth=4:

+ 85 - 0
src/MoonSharp.Interpreter.Tests/_Projects/MoonSharp.Interpreter.Tests.Embeddable.portable40/TestMore/222-constructor.t

@@ -0,0 +1,85 @@
+#! /usr/bin/lua
+--
+-- lua-TestMore : <http://fperrad.github.com/lua-TestMore/>
+--
+-- Copyright (C) 2009-2010, Perrad Francois
+--
+-- This code is licensed under the terms of the MIT/X11 license,
+-- like Lua itself.
+--
+
+--[[
+
+=head1 Lua Table Constructors
+
+=head2 Synopsis
+
+    % prove 222-constructor.t
+
+=head2 Description
+
+See "Lua 5.2 Reference Manual", section 3.4.8 "Table Constructors",
+L<http://www.lua.org/manual/5.2/manual.html#3.4.8>.
+
+See "Programming in Lua", section 3.6 "Table Constructors".
+
+=cut
+
+--]]
+
+require 'Test.More'
+
+plan(14)
+
+--[[ list-style init ]]
+days = {'Sunday', 'Monday', 'Tuesday', 'Wednesday',
+        'Thursday', 'Friday', 'Saturday'}
+is(days[4], 'Wednesday', "list-style init")
+is(#days, 7)
+
+--[[ record-style init ]]
+a = {x=0, y=0}
+is(a.x, 0, "record-style init")
+is(a.y, 0)
+
+--[[ ]]
+w = {x=0, y=0, label='console'}
+x = {0, 1, 2}
+w[1] = "another field"
+x.f = w
+is(w['x'], 0, "ctor")
+is(w[1], "another field")
+is(x.f[1], "another field")
+w.x = nil
+
+--[[ mix record-style and list-style init ]]
+polyline = {color='blue', thickness=2, npoints=4,
+             {x=0,   y=0},
+             {x=-10, y=0},
+             {x=-10, y=1},
+             {x=0,   y=1}
+           }
+is(polyline[2].x, -10, "mix record-style and list-style init")
+
+--[[ ]]
+opnames = {['+'] = 'add', ['-'] = 'sub',
+           ['*'] = 'mul', ['/'] = 'div'}
+i = 20; s = '-'
+a = {[i+0] = s, [i+1] = s..s, [i+2] = s..s..s}
+is(opnames[s], 'sub', "ctor")
+is(a[22], '---')
+
+--[[ ]]
+local function f() return 10, 20 end
+
+eq_array({f()}, {10, 20}, "ctor")
+eq_array({'a', f()}, {'a', 10, 20})
+eq_array({f(), 'b'}, {10, 'b'})
+eq_array({'c', (f())}, {'c', 10})
+
+-- Local Variables:
+--   mode: lua
+--   lua-indent-level: 4
+--   fill-column: 100
+-- End:
+-- vim: ft=lua expandtab shiftwidth=4:

Some files were not shown because too many files changed in this diff