Website Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit67025e787fa572e19e1f9837d910c725ea4ff022 (patch)
Author
 martin dobrev <martindobrev0@gmail.com>
2018-10-24 22:13:48 +0300
Committer
 martin dobrev <martindobrev0@gmail.com>
2018-10-24 22:13:48 +0300
Files17075488f5af011cc2c6c2228aeaadbdfbe18946
IPL-67025e787fa572e19e1f9837d910c725ea4ff022.tar
IPL-67025e787fa572e19e1f9837d910c725ea4ff022.tar.gz
IPL-67025e787fa572e19e1f9837d910c725ea4ff022.zip
Parent6dd6e47076a5511a3d3a73247b149d02dfa9e2aa (diff)
Add test app.
9 files changed, 436 insertions, 285 deletions
-rw-r--r--JSImpl/JS.Common/JS.Common.vcxitems34
-rw-r--r--JSImpl/projects/JS.Common/JS.Common.vcxitems34
-rw-r--r--JSImpl/projects/JS.Common/JS.Common.vcxitems.filters (renamed from JSImpl/JS.Common/JS.Common.vcxitems.filters)32
-rw-r--r--JSImpl/projects/TestApp/TestApp.vcxproj121
-rw-r--r--JSImpl/projects/TestApp/TestApp.vcxproj.filters6
-rw-r--r--JSImpl/solution/JSImpl.sln17
-rw-r--r--JSImpl/solution/JSImpl.vcxproj2
-rw-r--r--JSImpl/src/Tests/main.cpp244
-rw-r--r--JSImpl/src/main.cpp231
diff --git a/JSImpl/JS.Common/JS.Common.vcxitems b/JSImpl/JS.Common/JS.Common.vcxitems
deleted file mode 100644
index 0aa7ad7..0000000
--- a/JSImpl/JS.Common/JS.Common.vcxitems
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup Label="Globals">
- <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
- <HasSharedItems>true</HasSharedItems>
- <ItemsProjectGuid>{45d41acc-2c3c-43d2-bc10-02aa73ffc7c7}</ItemsProjectGuid>
- </PropertyGroup>
- <ItemDefinitionGroup>
- <ClCompile>
- <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory)</AdditionalIncludeDirectories>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ProjectCapability Include="SourceItemsFromImports" />
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="$(MSBuildThisFileDirectory)..\src\ASTInterpreter.cpp" />
- <ClCompile Include="$(MSBuildThisFileDirectory)..\src\ASTPrinter.cpp" />
- <ClCompile Include="$(MSBuildThisFileDirectory)..\src\Expression.cpp" />
- <ClCompile Include="$(MSBuildThisFileDirectory)..\src\Lexer.cpp" />
- <ClCompile Include="$(MSBuildThisFileDirectory)..\src\Parser.cpp" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="$(MSBuildThisFileDirectory)..\src\ASTInterpreter.h" />
- <ClInclude Include="$(MSBuildThisFileDirectory)..\src\ASTPrinter.h" />
- <ClInclude Include="$(MSBuildThisFileDirectory)..\src\CommonTypes.h" />
- <ClInclude Include="$(MSBuildThisFileDirectory)..\src\Expression.h" />
- <ClInclude Include="$(MSBuildThisFileDirectory)..\src\ExpressionDefinitions.h" />
- <ClInclude Include="$(MSBuildThisFileDirectory)..\src\ExpressionsFwd.h" />
- <ClInclude Include="$(MSBuildThisFileDirectory)..\src\ExpressionVisitor.h" />
- <ClInclude Include="$(MSBuildThisFileDirectory)..\src\Lexer.h" />
- <ClInclude Include="$(MSBuildThisFileDirectory)..\src\Parser.h" />
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/JSImpl/projects/JS.Common/JS.Common.vcxitems b/JSImpl/projects/JS.Common/JS.Common.vcxitems
new file mode 100644
index 0000000..0f2ec7d
--- /dev/null
+++ b/JSImpl/projects/JS.Common/JS.Common.vcxitems
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup Label="Globals">
+ <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
+ <HasSharedItems>true</HasSharedItems>
+ <ItemsProjectGuid>{45d41acc-2c3c-43d2-bc10-02aa73ffc7c7}</ItemsProjectGuid>
+ </PropertyGroup>
+ <ItemDefinitionGroup>
+ <ClCompile>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory)</AdditionalIncludeDirectories>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ProjectCapability Include="SourceItemsFromImports" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="$(MSBuildThisFileDirectory)..\..\src\ASTInterpreter.cpp" />
+ <ClCompile Include="$(MSBuildThisFileDirectory)..\..\src\ASTPrinter.cpp" />
+ <ClCompile Include="$(MSBuildThisFileDirectory)..\..\src\Expression.cpp" />
+ <ClCompile Include="$(MSBuildThisFileDirectory)..\..\src\Lexer.cpp" />
+ <ClCompile Include="$(MSBuildThisFileDirectory)..\..\src\Parser.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\src\ASTInterpreter.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\src\ASTPrinter.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\src\CommonTypes.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\src\Expression.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\src\ExpressionDefinitions.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\src\ExpressionsFwd.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\src\ExpressionVisitor.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\src\Lexer.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\src\Parser.h" />
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/JSImpl/JS.Common/JS.Common.vcxitems.filters b/JSImpl/projects/JS.Common/JS.Common.vcxitems.filters
index 9d4ce31..f213e40 100644
--- a/JSImpl/JS.Common/JS.Common.vcxitems.filters
+++ b/JSImpl/projects/JS.Common/JS.Common.vcxitems.filters
@@ -15,47 +15,47 @@
</Filter>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="$(MSBuildThisFileDirectory)..\src\Expression.cpp">
+ <ClCompile Include="$(MSBuildThisFileDirectory)..\..\src\Expression.cpp">
<Filter>Expressions</Filter>
</ClCompile>
- <ClCompile Include="$(MSBuildThisFileDirectory)..\src\Lexer.cpp">
+ <ClCompile Include="$(MSBuildThisFileDirectory)..\..\src\Lexer.cpp">
<Filter>Lexer</Filter>
</ClCompile>
- <ClCompile Include="$(MSBuildThisFileDirectory)..\src\Parser.cpp">
+ <ClCompile Include="$(MSBuildThisFileDirectory)..\..\src\Parser.cpp">
<Filter>Parser</Filter>
</ClCompile>
- <ClCompile Include="$(MSBuildThisFileDirectory)..\src\ASTInterpreter.cpp">
+ <ClCompile Include="$(MSBuildThisFileDirectory)..\..\src\ASTInterpreter.cpp">
<Filter>Visitors</Filter>
</ClCompile>
- <ClCompile Include="$(MSBuildThisFileDirectory)..\src\ASTPrinter.cpp">
+ <ClCompile Include="$(MSBuildThisFileDirectory)..\..\src\ASTPrinter.cpp">
<Filter>Visitors</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
- <ClInclude Include="$(MSBuildThisFileDirectory)..\src\Expression.h">
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\src\Expression.h">
<Filter>Expressions</Filter>
</ClInclude>
- <ClInclude Include="$(MSBuildThisFileDirectory)..\src\ExpressionDefinitions.h">
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\src\ExpressionDefinitions.h">
<Filter>Expressions</Filter>
</ClInclude>
- <ClInclude Include="$(MSBuildThisFileDirectory)..\src\ExpressionsFwd.h">
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\src\ExpressionsFwd.h">
<Filter>Expressions</Filter>
</ClInclude>
- <ClInclude Include="$(MSBuildThisFileDirectory)..\src\Lexer.h">
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\src\ExpressionVisitor.h">
+ <Filter>Expressions</Filter>
+ </ClInclude>
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\src\Lexer.h">
<Filter>Lexer</Filter>
</ClInclude>
- <ClInclude Include="$(MSBuildThisFileDirectory)..\src\Parser.h">
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\src\Parser.h">
<Filter>Parser</Filter>
</ClInclude>
- <ClInclude Include="$(MSBuildThisFileDirectory)..\src\ASTInterpreter.h">
- <Filter>Visitors</Filter>
- </ClInclude>
- <ClInclude Include="$(MSBuildThisFileDirectory)..\src\ASTPrinter.h">
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\src\ASTInterpreter.h">
<Filter>Visitors</Filter>
</ClInclude>
- <ClInclude Include="$(MSBuildThisFileDirectory)..\src\ExpressionVisitor.h">
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\src\ASTPrinter.h">
<Filter>Visitors</Filter>
</ClInclude>
- <ClInclude Include="$(MSBuildThisFileDirectory)..\src\CommonTypes.h" />
+ <ClInclude Include="$(MSBuildThisFileDirectory)..\..\src\CommonTypes.h" />
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/JSImpl/projects/TestApp/TestApp.vcxproj b/JSImpl/projects/TestApp/TestApp.vcxproj
new file mode 100644
index 0000000..e37f61d
--- /dev/null
+++ b/JSImpl/projects/TestApp/TestApp.vcxproj
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{05DB0989-2720-45CC-8689-2FF047B4FD74}</ProjectGuid>
+ <RootNamespace>TestApp</RootNamespace>
+ <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v140</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="Shared">
+ <Import Project="..\JS.Common\JS.Common.vcxitems" Label="Shared" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup />
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>true</SDLCheck>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ </ClCompile>
+ <Link>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>$(ProjectDir)../../src/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\src\Tests\main.cpp" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/JSImpl/projects/TestApp/TestApp.vcxproj.filters b/JSImpl/projects/TestApp/TestApp.vcxproj.filters
new file mode 100644
index 0000000..5a05e58
--- /dev/null
+++ b/JSImpl/projects/TestApp/TestApp.vcxproj.filters
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <ClCompile Include="..\..\src\Tests\main.cpp" />
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/JSImpl/solution/JSImpl.sln b/JSImpl/solution/JSImpl.sln
index a2f0672..9deeed2 100644
--- a/JSImpl/solution/JSImpl.sln
+++ b/JSImpl/solution/JSImpl.sln
@@ -5,12 +5,15 @@ VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JSImpl", "JSImpl.vcxproj", "{EE0F8C6F-3619-4A46-BC19-FAEAD4167EE4}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JS.Common", "..\JS.Common\JS.Common.vcxitems", "{45D41ACC-2C3C-43D2-BC10-02AA73FFC7C7}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JS.Common", "..\projects\JS.Common\JS.Common.vcxitems", "{45D41ACC-2C3C-43D2-BC10-02AA73FFC7C7}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestApp", "..\projects\TestApp\TestApp.vcxproj", "{05DB0989-2720-45CC-8689-2FF047B4FD74}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
- ..\JS.Common\JS.Common.vcxitems*{45d41acc-2c3c-43d2-bc10-02aa73ffc7c7}*SharedItemsImports = 9
- ..\JS.Common\JS.Common.vcxitems*{ee0f8c6f-3619-4a46-bc19-faead4167ee4}*SharedItemsImports = 4
+ ..\projects\JS.Common\JS.Common.vcxitems*{05db0989-2720-45cc-8689-2ff047b4fd74}*SharedItemsImports = 4
+ ..\projects\JS.Common\JS.Common.vcxitems*{45d41acc-2c3c-43d2-bc10-02aa73ffc7c7}*SharedItemsImports = 9
+ ..\projects\JS.Common\JS.Common.vcxitems*{ee0f8c6f-3619-4a46-bc19-faead4167ee4}*SharedItemsImports = 4
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@@ -27,6 +30,14 @@ Global
{EE0F8C6F-3619-4A46-BC19-FAEAD4167EE4}.Release|x64.Build.0 = Release|x64
{EE0F8C6F-3619-4A46-BC19-FAEAD4167EE4}.Release|x86.ActiveCfg = Release|Win32
{EE0F8C6F-3619-4A46-BC19-FAEAD4167EE4}.Release|x86.Build.0 = Release|Win32
+ {05DB0989-2720-45CC-8689-2FF047B4FD74}.Debug|x64.ActiveCfg = Debug|x64
+ {05DB0989-2720-45CC-8689-2FF047B4FD74}.Debug|x64.Build.0 = Debug|x64
+ {05DB0989-2720-45CC-8689-2FF047B4FD74}.Debug|x86.ActiveCfg = Debug|Win32
+ {05DB0989-2720-45CC-8689-2FF047B4FD74}.Debug|x86.Build.0 = Debug|Win32
+ {05DB0989-2720-45CC-8689-2FF047B4FD74}.Release|x64.ActiveCfg = Release|x64
+ {05DB0989-2720-45CC-8689-2FF047B4FD74}.Release|x64.Build.0 = Release|x64
+ {05DB0989-2720-45CC-8689-2FF047B4FD74}.Release|x86.ActiveCfg = Release|Win32
+ {05DB0989-2720-45CC-8689-2FF047B4FD74}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/JSImpl/solution/JSImpl.vcxproj b/JSImpl/solution/JSImpl.vcxproj
index 32d6b96..39beeba 100644
--- a/JSImpl/solution/JSImpl.vcxproj
+++ b/JSImpl/solution/JSImpl.vcxproj
@@ -54,7 +54,7 @@
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
- <Import Project="..\JS.Common\JS.Common.vcxitems" Label="Shared" />
+ <Import Project="..\projects\JS.Common\JS.Common.vcxitems" Label="Shared" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
diff --git a/JSImpl/src/Tests/main.cpp b/JSImpl/src/Tests/main.cpp
new file mode 100644
index 0000000..f92144a
--- /dev/null
+++ b/JSImpl/src/Tests/main.cpp
@@ -0,0 +1,244 @@
+#include "Lexer.h"
+#include "Parser.h"
+#include "ASTPrinter.h"
+#include "ASTInterpreter.h"
+#include <iostream>
+#define LOG(msg) std::cout << msg << std::endl
+#define EXECUTE_TEST(test) std::cout << #test << " "; test();
+
+#define CHECK(cond) if (cond) {LOG("PASS");} else {LOG(#cond " FAIL");}
+
+// Lexer Tests
+void TestLess()
+{
+ IPLVector<Token> tokens;
+ Tokenize("<", tokens);
+
+ CHECK(tokens.size() == 2 && tokens[0].Type == TokenType::Less);
+}
+
+void TestNumber()
+{
+ IPLVector<Token> tokens;
+ Tokenize("213434.24", tokens);
+
+ CHECK(tokens.size() == 2 && tokens[0].Type == TokenType::Number && tokens[0].Number == 213434.24);
+}
+
+void TestNumberStartWithNine()
+{
+ IPLVector<Token> tokens;
+ Tokenize("999", tokens);
+ CHECK(tokens.size() == 2 && tokens[0].Type == TokenType::Number && tokens[0].Number == 999);
+}
+
+void TestNumberStartWithZero()
+{
+ IPLVector<Token> tokens;
+ Tokenize("0999", tokens);
+ CHECK(tokens.size() == 2 && tokens[0].Type == TokenType::Number && tokens[0].Number == 999);
+}
+
+void TestSpaceNewLineSpace()
+{
+ IPLVector<Token> tokens;
+ Tokenize(" \n var a = 4; ", tokens);
+ CHECK(tokens.size() == 6 && tokens[0].Type == TokenType::Var &&
+ tokens[1].Type == TokenType::Identifier &&
+ tokens[2].Type == TokenType::Equal &&
+ tokens[3].Type == TokenType::Number &&
+ tokens[4].Type == TokenType::Semicolon);
+}
+
+void TestString()
+{
+ IPLVector<Token> tokens;
+ Tokenize("\"alabala\"", tokens);
+ CHECK(tokens.size() == 2 && tokens[0].Type == TokenType::String && tokens[0].Lexeme == "\"alabala\"");
+}
+
+void TestStringSingleQuotedStrings()
+{
+ IPLVector<Token> tokens;
+ Tokenize("'alabala'", tokens);
+ CHECK(tokens.size() == 2 && tokens[0].Type == TokenType::String && tokens[0].Lexeme == "'alabala'");
+}
+
+void TestKeyWord()
+{
+ IPLVector<Token> tokens;
+ Tokenize("for", tokens);
+ CHECK(tokens.size() == 2 && tokens[0].Type == TokenType::For);
+}
+
+void TestVariableDeclaration()
+{
+ IPLVector<Token> tokens;
+ Tokenize("var pesho = 10", tokens);
+
+ CHECK(tokens.size() == 5 && tokens[0].Type == TokenType::Var
+ && tokens[1].Type == TokenType::Identifier
+ && tokens[2].Type == TokenType::Equal
+ && tokens[3].Type == TokenType::Number
+ && tokens[4].Type == TokenType::Eof);
+}
+
+void TestStringError()
+{
+ IPLVector<Token> tokens;
+ const auto& res = Tokenize("\" aaaa", tokens);
+ CHECK(!res.IsSuccessful && res.Error.Row == 0 && res.Error.Column == 6);
+}
+
+void TestWhiteSpaceTokens()
+{
+ IPLVector<Token> tokens;
+ const auto& res = Tokenize(" 1\n2 abc\n \n", tokens, { true, false });
+ CHECK(res.IsSuccessful
+ && tokens.size() == 8
+ && tokens[0].Type == TokenType::Whitespace
+ && tokens[0].Lexeme == " "
+ && tokens[1].Type == TokenType::Number
+ && tokens[1].Number == 1
+ && tokens[2].Type == TokenType::Whitespace
+ && tokens[2].Lexeme == "\n"
+ && tokens[3].Type == TokenType::Number
+ && tokens[3].Number == 2
+ && tokens[4].Type == TokenType::Whitespace
+ && tokens[4].Lexeme == " "
+ && tokens[5].Type == TokenType::Identifier
+ && tokens[5].Lexeme == "abc"
+ && tokens[6].Type == TokenType::Whitespace
+ && tokens[6].Lexeme == "\n \n"
+ && tokens[7].Type == TokenType::Eof);
+}
+
+void TestSimpleComment()
+{
+ IPLVector<Token> tokens;
+ const auto& res = Tokenize("//comment", tokens, { false, true });
+ CHECK(res.IsSuccessful
+ && tokens.size() == 2
+ && tokens[0].Type == TokenType::Comment
+ && tokens[0].Lexeme == "//comment"
+ && tokens[1].Type == TokenType::Eof);
+}
+
+void TestSimpleMultiLineComment()
+{
+ IPLVector<Token> tokens;
+ const auto& res = Tokenize("/*comment\ncomment*/", tokens, { false, true });
+ CHECK(res.IsSuccessful
+ && tokens.size() == 2
+ && tokens[0].Type == TokenType::Comment
+ && tokens[0].Lexeme == "/*comment\ncomment*/"
+ && tokens[1].Type == TokenType::Eof);
+}
+
+void TestConsecutiveMultiLineComment()
+{
+ IPLVector<Token> tokens;
+ const auto& res = Tokenize("/*comment1\ncomment1*//*comment2\ncomment2*/", tokens, { false, true });
+ CHECK(res.IsSuccessful
+ && tokens.size() == 3
+ && tokens[0].Type == TokenType::Comment
+ && tokens[0].Lexeme == "/*comment1\ncomment1*/"
+ && tokens[1].Type == TokenType::Comment
+ && tokens[1].Lexeme == "/*comment2\ncomment2*/"
+ && tokens[2].Type == TokenType::Eof);
+}
+
+void TestConsecutiveMultiLineCommentWithSpace()
+{
+ IPLVector<Token> tokens;
+ const auto& res = Tokenize("/*comment1\ncomment1*/\n\n\n/*comment2\ncomment2*/", tokens, { false, true });
+ CHECK(res.IsSuccessful
+ && tokens.size() == 3
+ && tokens[0].Type == TokenType::Comment
+ && tokens[0].Lexeme == "/*comment1\ncomment1*/"
+ && tokens[1].Type == TokenType::Comment
+ && tokens[1].Lexeme == "/*comment2\ncomment2*/"
+ && tokens[2].Type == TokenType::Eof);
+}
+
+void TestConsecutiveMultiLineCommentWithSpaceWithTokens()
+{
+ IPLVector<Token> tokens;
+ const auto& res = Tokenize("//comment1\n/*comment2\ncomment2*/\n\n\n/*comment3\ncomment3*/", tokens, { true, true });
+ CHECK(res.IsSuccessful
+ && tokens.size() == 6
+ && tokens[0].Type == TokenType::Comment
+ && tokens[0].Lexeme == "//comment1"
+ && tokens[1].Type == TokenType::Whitespace
+ && tokens[1].Lexeme == "\n"
+ && tokens[2].Type == TokenType::Comment
+ && tokens[2].Lexeme == "/*comment2\ncomment2*/"
+ && tokens[3].Type == TokenType::Whitespace
+ && tokens[3].Lexeme == "\n\n\n"
+ && tokens[4].Type == TokenType::Comment
+ && tokens[4].Lexeme == "/*comment3\ncomment3*/"
+ && tokens[5].Type == TokenType::Eof);
+}
+
+void TestCommentError()
+{
+ IPLVector<Token> tokens;
+ const auto& res = Tokenize(" aa\n /*", tokens);
+ CHECK(!res.IsSuccessful && res.Error.Row == 1 && res.Error.Column == 3);
+}
+
+// Parser Tests
+void TestParseUnaryExpr()
+{
+ IPLVector<Token> tokens;
+ Tokenize("function pesho() { var a = 0; return a; } var a = \"3\";", tokens);
+
+ // TODO make actual test :D
+ auto expr = Parse(tokens);
+ ASTPrinter p(std::cout);
+ expr->Accept(p);
+ std::cout << "\n";
+}
+
+void TestHexNumber()
+{
+ IPLVector<Token> tokens;
+ const auto& res = Tokenize("0x10", tokens);
+
+ CHECK(res.IsSuccessful && tokens[0].Type == TokenType::Number && tokens[0].Number == 16);
+}
+
+void TestScientificNotationNumber()
+{
+ IPLVector<Token> tokens;
+ const auto& res = Tokenize("1e2", tokens);
+
+ CHECK(res.IsSuccessful && tokens[0].Type == TokenType::Number && tokens[0].Number == 100);
+}
+
+int main()
+{
+ EXECUTE_TEST(TestLess);
+ EXECUTE_TEST(TestNumber);
+ EXECUTE_TEST(TestNumberStartWithNine);
+ EXECUTE_TEST(TestNumberStartWithZero);
+ EXECUTE_TEST(TestString);
+ EXECUTE_TEST(TestSpaceNewLineSpace);
+ EXECUTE_TEST(TestStringSingleQuotedStrings);
+ EXECUTE_TEST(TestKeyWord);
+ EXECUTE_TEST(TestVariableDeclaration);
+ EXECUTE_TEST(TestWhiteSpaceTokens);
+ EXECUTE_TEST(TestSimpleComment);
+ EXECUTE_TEST(TestSimpleMultiLineComment);
+ EXECUTE_TEST(TestConsecutiveMultiLineComment);
+ EXECUTE_TEST(TestConsecutiveMultiLineCommentWithSpace);
+ EXECUTE_TEST(TestConsecutiveMultiLineCommentWithSpaceWithTokens);
+ EXECUTE_TEST(TestCommentError);
+ EXECUTE_TEST(TestHexNumber);
+ EXECUTE_TEST(TestScientificNotationNumber);
+
+#if defined(_WIN32)
+ std::system("pause");
+#endif
+ return 0;
+}
diff --git a/JSImpl/src/main.cpp b/JSImpl/src/main.cpp
index 3cb3be5..5f2ce2b 100644
--- a/JSImpl/src/main.cpp
+++ b/JSImpl/src/main.cpp
@@ -3,202 +3,6 @@
#include "ASTPrinter.h"
#include "ASTInterpreter.h"
#include <iostream>
-#define LOG(msg) std::cout << msg << std::endl
-#define EXECUTE_TEST(test) std::cout << #test << " "; test();
-
-#define CHECK(cond) if (cond) {LOG("PASS");} else {LOG(#cond " FAIL");}
-
-// Lexer Tests
-void TestLess()
-{
- IPLVector<Token> tokens;
- Tokenize("<", tokens);
-
- CHECK(tokens.size() == 2 && tokens[0].Type == TokenType::Less);
-}
-
-void TestNumber()
-{
- IPLVector<Token> tokens;
- Tokenize("213434.24", tokens);
-
- CHECK(tokens.size() == 2 && tokens[0].Type == TokenType::Number && tokens[0].Number == 213434.24);
-}
-
-void TestNumberStartWithNine()
-{
- IPLVector<Token> tokens;
- Tokenize("999", tokens);
- CHECK(tokens.size() == 2 && tokens[0].Type == TokenType::Number && tokens[0].Number == 999);
-}
-
-void TestNumberStartWithZero()
-{
- IPLVector<Token> tokens;
- Tokenize("0999", tokens);
- CHECK(tokens.size() == 2 && tokens[0].Type == TokenType::Number && tokens[0].Number == 999);
-}
-
-void TestSpaceNewLineSpace()
-{
- IPLVector<Token> tokens;
- Tokenize(" \n var a = 4; ", tokens);
- CHECK(tokens.size() == 6 && tokens[0].Type == TokenType::Var &&
- tokens[1].Type == TokenType::Identifier &&
- tokens[2].Type == TokenType::Equal &&
- tokens[3].Type == TokenType::Number &&
- tokens[4].Type == TokenType::Semicolon);
-}
-
-void TestString()
-{
- IPLVector<Token> tokens;
- Tokenize("\"alabala\"", tokens);
- CHECK(tokens.size() == 2 && tokens[0].Type == TokenType::String && tokens[0].Lexeme == "\"alabala\"");
-}
-
-void TestStringSingleQuotedStrings()
-{
- IPLVector<Token> tokens;
- Tokenize("'alabala'", tokens);
- CHECK(tokens.size() == 2 && tokens[0].Type == TokenType::String && tokens[0].Lexeme == "'alabala'");
-}
-
-void TestKeyWord()
-{
- IPLVector<Token> tokens;
- Tokenize("for", tokens);
- CHECK(tokens.size() == 2 && tokens[0].Type == TokenType::For);
-}
-
-void TestVariableDeclaration()
-{
- IPLVector<Token> tokens;
- Tokenize("var pesho = 10", tokens);
-
- CHECK(tokens.size() == 5 && tokens[0].Type == TokenType::Var
- && tokens[1].Type == TokenType::Identifier
- && tokens[2].Type == TokenType::Equal
- && tokens[3].Type == TokenType::Number
- && tokens[4].Type == TokenType::Eof);
-}
-
-void TestStringError()
-{
- IPLVector<Token> tokens;
- const auto& res = Tokenize("\" aaaa", tokens);
- CHECK(!res.IsSuccessful && res.Error.Row == 0 && res.Error.Column == 6);
-}
-
-void TestWhiteSpaceTokens()
-{
- IPLVector<Token> tokens;
- const auto& res = Tokenize(" 1\n2 abc\n \n", tokens, { true, false });
- CHECK(res.IsSuccessful
- && tokens.size() == 8
- && tokens[0].Type == TokenType::Whitespace
- && tokens[0].Lexeme == " "
- && tokens[1].Type == TokenType::Number
- && tokens[1].Number == 1
- && tokens[2].Type == TokenType::Whitespace
- && tokens[2].Lexeme == "\n"
- && tokens[3].Type == TokenType::Number
- && tokens[3].Number == 2
- && tokens[4].Type == TokenType::Whitespace
- && tokens[4].Lexeme == " "
- && tokens[5].Type == TokenType::Identifier
- && tokens[5].Lexeme == "abc"
- && tokens[6].Type == TokenType::Whitespace
- && tokens[6].Lexeme == "\n \n"
- && tokens[7].Type == TokenType::Eof);
-}
-
-void TestSimpleComment()
-{
- IPLVector<Token> tokens;
- const auto& res = Tokenize("//comment", tokens, { false, true });
- CHECK(res.IsSuccessful
- && tokens.size() == 2
- && tokens[0].Type == TokenType::Comment
- && tokens[0].Lexeme == "//comment"
- && tokens[1].Type == TokenType::Eof);
-}
-
-void TestSimpleMultiLineComment()
-{
- IPLVector<Token> tokens;
- const auto& res = Tokenize("/*comment\ncomment*/", tokens, { false, true });
- CHECK(res.IsSuccessful
- && tokens.size() == 2
- && tokens[0].Type == TokenType::Comment
- && tokens[0].Lexeme == "/*comment\ncomment*/"
- && tokens[1].Type == TokenType::Eof);
-}
-
-void TestConsecutiveMultiLineComment()
-{
- IPLVector<Token> tokens;
- const auto& res = Tokenize("/*comment1\ncomment1*//*comment2\ncomment2*/", tokens, { false, true });
- CHECK(res.IsSuccessful
- && tokens.size() == 3
- && tokens[0].Type == TokenType::Comment
- && tokens[0].Lexeme == "/*comment1\ncomment1*/"
- && tokens[1].Type == TokenType::Comment
- && tokens[1].Lexeme == "/*comment2\ncomment2*/"
- && tokens[2].Type == TokenType::Eof);
-}
-
-void TestConsecutiveMultiLineCommentWithSpace()
-{
- IPLVector<Token> tokens;
- const auto& res = Tokenize("/*comment1\ncomment1*/\n\n\n/*comment2\ncomment2*/", tokens, { false, true });
- CHECK(res.IsSuccessful
- && tokens.size() == 3
- && tokens[0].Type == TokenType::Comment
- && tokens[0].Lexeme == "/*comment1\ncomment1*/"
- && tokens[1].Type == TokenType::Comment
- && tokens[1].Lexeme == "/*comment2\ncomment2*/"
- && tokens[2].Type == TokenType::Eof);
-}
-
-void TestConsecutiveMultiLineCommentWithSpaceWithTokens()
-{
- IPLVector<Token> tokens;
- const auto& res = Tokenize("//comment1\n/*comment2\ncomment2*/\n\n\n/*comment3\ncomment3*/", tokens, { true, true });
- CHECK(res.IsSuccessful
- && tokens.size() == 6
- && tokens[0].Type == TokenType::Comment
- && tokens[0].Lexeme == "//comment1"
- && tokens[1].Type == TokenType::Whitespace
- && tokens[1].Lexeme == "\n"
- && tokens[2].Type == TokenType::Comment
- && tokens[2].Lexeme == "/*comment2\ncomment2*/"
- && tokens[3].Type == TokenType::Whitespace
- && tokens[3].Lexeme == "\n\n\n"
- && tokens[4].Type == TokenType::Comment
- && tokens[4].Lexeme == "/*comment3\ncomment3*/"
- && tokens[5].Type == TokenType::Eof);
-}
-
-void TestCommentError()
-{
- IPLVector<Token> tokens;
- const auto& res = Tokenize(" aa\n /*", tokens);
- CHECK(!res.IsSuccessful && res.Error.Row == 1 && res.Error.Column == 3);
-}
-
-// Parser Tests
-void TestParseUnaryExpr()
-{
- IPLVector<Token> tokens;
- Tokenize("function pesho() { var a = 0; return a; } var a = \"3\";", tokens);
-
- // TODO make actual test :D
- auto expr = Parse(tokens);
- ASTPrinter p(std::cout);
- expr->Accept(p);
- std::cout << "\n";
-}
void RunParseCalc()
{
@@ -221,44 +25,9 @@ void RunParseCalc()
std::cout << "S = " << i.ModifyVariable("s") << std::endl;
}
-void TestHexNumber()
-{
- IPLVector<Token> tokens;
- const auto& res = Tokenize("0x10", tokens);
-
- CHECK(res.IsSuccessful && tokens[0].Type == TokenType::Number && tokens[0].Number == 16);
-}
-
-void TestScientificNotationNumber()
-{
- IPLVector<Token> tokens;
- const auto& res = Tokenize("1e2", tokens);
-
- CHECK(res.IsSuccessful && tokens[0].Type == TokenType::Number && tokens[0].Number == 100);
-}
-
int main()
{
- EXECUTE_TEST(TestLess);
- EXECUTE_TEST(TestNumber);
- EXECUTE_TEST(TestNumberStartWithNine);
- EXECUTE_TEST(TestNumberStartWithZero);
- EXECUTE_TEST(TestString);
- EXECUTE_TEST(TestSpaceNewLineSpace);
- EXECUTE_TEST(TestStringSingleQuotedStrings);
- EXECUTE_TEST(TestKeyWord);
- EXECUTE_TEST(TestVariableDeclaration);
- EXECUTE_TEST(TestWhiteSpaceTokens);
- EXECUTE_TEST(TestSimpleComment);
- EXECUTE_TEST(TestSimpleMultiLineComment);
- EXECUTE_TEST(TestConsecutiveMultiLineComment);
- EXECUTE_TEST(TestConsecutiveMultiLineCommentWithSpace);
- EXECUTE_TEST(TestConsecutiveMultiLineCommentWithSpaceWithTokens);
- EXECUTE_TEST(TestCommentError);
- EXECUTE_TEST(TestHexNumber);
- EXECUTE_TEST(TestScientificNotationNumber);
- //TestParseUnaryExpr();
RunParseCalc();
#if defined(_WIN32)