diff options
| Commit | c32eda4e697803824e79878c74d541b81fbd04d8 (patch) | |
|---|---|---|
| Author | 2018-11-15 11:35:44 +0200 | |
| Committer | 2018-11-15 11:35:44 +0200 | |
| Files | ace7bdc0df3791b6db8878d52ba98cb368e180b8 /JSImpl/test | |
| IPL-c32eda4e697803824e79878c74d541b81fbd04d8.tar IPL-c32eda4e697803824e79878c74d541b81fbd04d8.tar.gz IPL-c32eda4e697803824e79878c74d541b81fbd04d8.zip | ||
| Parent | a7cd9d4f8d83024402bacb39786e5e1a018a0a04 (diff) | |
| Parent | d7b2e339ff06c64bcb1322eec396d4995da6b17a (diff) | |
Merge pull request #48 from SofiaCPP/feature/spasm_asm
Spasm tests and latest instruction set
9 files changed, 180 insertions, 76 deletions
| -rw-r--r-- | JSImpl/test/Test.make | 8 | ||||
| -rw-r--r-- | JSImpl/test/Test.vcxproj | 11 | ||||
| -rw-r--r-- | JSImpl/test/genie.lua | 63 | ||||
| -rw-r--r-- | JSImpl/test/gmock.vcxproj | 14 | ||||
| -rw-r--r-- | JSImpl/test/gmock.vcxproj.filters | 22 | ||||
| -rw-r--r-- | JSImpl/test/gtest.vcxproj | 12 | ||||
| -rw-r--r-- | JSImpl/test/gtest.vcxproj.filters | 16 | ||||
| -rw-r--r-- | JSImpl/test/gtest_main.vcxproj | 2 | ||||
| -rw-r--r-- | JSImpl/test/sprtTests.cpp | 108 |
diff --git a/JSImpl/test/Test.make b/JSImpl/test/Test.make index 4540d2d..e1a6ad4 100644 --- a/JSImpl/test/Test.make +++ b/JSImpl/test/Test.make @@ -47,7 +47,7 @@ ifeq ($(config),debug64) TARGETDIR = ../build/bin/Debug TARGET = $(TARGETDIR)/Test DEFINES += -D_SCL_SECURE_NO_WARNINGS - INCLUDES += -I"googletest/googletest/include" -I"googletest/googlemock/include" -I".." -I"../../spasm/src" + INCLUDES += -I"googletest/googletest/include" -I"googletest/googlemock/include" -I".." -I"../../spasm/src" -I"../../spasm/src/asm" ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP -MP $(DEFINES) $(INCLUDES) ALL_ASMFLAGS += $(ASMFLAGS) $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -Werror -Wall -Wextra -g -m64 ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -Werror -Wall -Wextra -g -m64 @@ -56,7 +56,7 @@ ifeq ($(config),debug64) ALL_OBJCPPFLAGS += $(CXXFLAGS) $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -Werror -Wall -Wextra -g -m64 -std=c++14 ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) ALL_LDFLAGS += $(LDFLAGS) -L"../build/bin/Debug" -L"." -m64 - LDDEPS += ../build/bin/Debug/libsprt.a ../build/bin/Debug/libJSLib.a ../build/bin/Debug/libgtest.a ../build/bin/Debug/libgmock.a ../build/bin/Debug/libgtest_main.a + LDDEPS += ../build/bin/Debug/libsprt.a ../build/bin/Debug/libspasm_lib.a ../build/bin/Debug/libJSLib.a ../build/bin/Debug/libgtest.a ../build/bin/Debug/libgmock.a ../build/bin/Debug/libgtest_main.a LIBS += $(LDDEPS) -lpthread EXTERNAL_LIBS += LINKOBJS = $(OBJECTS) @@ -80,7 +80,7 @@ ifeq ($(config),release64) TARGETDIR = ../build/bin/Release TARGET = $(TARGETDIR)/Test DEFINES += -D_SCL_SECURE_NO_WARNINGS - INCLUDES += -I"googletest/googletest/include" -I"googletest/googlemock/include" -I".." -I"../../spasm/src" + INCLUDES += -I"googletest/googletest/include" -I"googletest/googlemock/include" -I".." -I"../../spasm/src" -I"../../spasm/src/asm" ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP -MP $(DEFINES) $(INCLUDES) ALL_ASMFLAGS += $(ASMFLAGS) $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -Werror -Wall -Wextra -g -O3 -m64 ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -Werror -Wall -Wextra -g -O3 -m64 @@ -89,7 +89,7 @@ ifeq ($(config),release64) ALL_OBJCPPFLAGS += $(CXXFLAGS) $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -Werror -Wall -Wextra -g -O3 -m64 -std=c++14 ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) ALL_LDFLAGS += $(LDFLAGS) -L"../build/bin/Release" -L"." -m64 - LDDEPS += ../build/bin/Release/libsprt.a ../build/bin/Release/libJSLib.a ../build/bin/Release/libgtest.a ../build/bin/Release/libgmock.a ../build/bin/Release/libgtest_main.a + LDDEPS += ../build/bin/Release/libsprt.a ../build/bin/Release/libspasm_lib.a ../build/bin/Release/libJSLib.a ../build/bin/Release/libgtest.a ../build/bin/Release/libgmock.a ../build/bin/Release/libgtest_main.a LIBS += $(LDDEPS) -lpthread EXTERNAL_LIBS += LINKOBJS = $(OBJECTS) diff --git a/JSImpl/test/Test.vcxproj b/JSImpl/test/Test.vcxproj index 3a7058a..c099f1c 100644 --- a/JSImpl/test/Test.vcxproj +++ b/JSImpl/test/Test.vcxproj @@ -57,7 +57,7 @@ <ClCompile>
<AdditionalOptions> %(AdditionalOptions)</AdditionalOptions>
<Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>googletest\googletest\include;googletest\googlemock\include;..;..\..\spasm\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>googletest\googletest\include;googletest\googlemock\include;..;..\..\spasm\src;..\..\spasm\src\asm;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -72,7 +72,7 @@ </ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>googletest\googletest\include;googletest\googlemock\include;..;..\..\spasm\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>googletest\googletest\include;googletest\googlemock\include;..;..\..\spasm\src;..\..\spasm\src\asm;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
<SubSystem>Console</SubSystem>
@@ -87,7 +87,7 @@ <ClCompile>
<AdditionalOptions> %(AdditionalOptions)</AdditionalOptions>
<Optimization>MaxSpeed</Optimization>
- <AdditionalIncludeDirectories>googletest\googletest\include;googletest\googlemock\include;..;..\..\spasm\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>googletest\googletest\include;googletest\googlemock\include;..;..\..\spasm\src;..\..\spasm\src\asm;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<StringPooling>true</StringPooling>
@@ -102,7 +102,7 @@ </ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>googletest\googletest\include;googletest\googlemock\include;..;..\..\spasm\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>googletest\googletest\include;googletest\googlemock\include;..;..\..\spasm\src;..\..\spasm\src\asm;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
<SubSystem>Console</SubSystem>
@@ -129,6 +129,9 @@ <ProjectReference Include="..\..\spasm\solution\sprt.vcxproj">
<Project>{AE0A9E7C-9A41-9F0D-432E-85102F441B0F}</Project>
</ProjectReference>
+ <ProjectReference Include="..\..\spasm\solution\spasm_lib.vcxproj">
+ <Project>{3F16CDE1-AB80-8158-F4BE-32FE60685FAD}</Project>
+ </ProjectReference>
<ProjectReference Include="..\solution\JSLib.vcxproj">
<Project>{19EA680D-85FE-90BE-4E80-341EBA538DEF}</Project>
</ProjectReference>
diff --git a/JSImpl/test/genie.lua b/JSImpl/test/genie.lua index ba0f0c2..c3cd1d6 100644 --- a/JSImpl/test/genie.lua +++ b/JSImpl/test/genie.lua @@ -10,9 +10,11 @@ project 'Test' 'googletest/googlemock/include', '..', '../../spasm/src', + '../../spasm/src/asm', } links { 'sprt', + 'spasm_lib', 'JSLib', 'gtest', 'gmock', @@ -22,35 +24,36 @@ project 'Test' links 'pthread' configuration '*' -project 'gtest' - kind 'StaticLib' - language 'C++' - uuid(os.uuid('gtest')) - files 'googletest/googletest/src/gtest-all.cc' - files 'googletest/googletest/include/gtest/*.h' - includedirs { - 'googletest/googletest', - 'googletest/googletest/include', - } +group 'gtest' + project 'gtest' + kind 'StaticLib' + language 'C++' + uuid(os.uuid('gtest')) + files 'googletest/googletest/src/gtest-all.cc' + files 'googletest/googletest/include/gtest/*.h' + includedirs { + 'googletest/googletest', + 'googletest/googletest/include', + } -project 'gmock' - kind 'StaticLib' - language 'C++' - uuid(os.uuid('gmock')) - files 'googletest/googlemock/src/gmock-all.cc' - files 'googletest/googlemock/include/gmock/*.h' - includedirs { - 'googletest/googlemock', - 'googletest/googlemock/include', - 'googletest/googletest/include', - } + project 'gmock' + kind 'StaticLib' + language 'C++' + uuid(os.uuid('gmock')) + files 'googletest/googlemock/src/gmock-all.cc' + files 'googletest/googlemock/include/gmock/*.h' + includedirs { + 'googletest/googlemock', + 'googletest/googlemock/include', + 'googletest/googletest/include', + } -project 'gtest_main' - kind 'StaticLib' - language 'C++' - uuid(os.uuid('gtest_main')) - files 'googletest/googletest/src/gtest_main.cc' - includedirs { - 'googletest/googletest', - 'googletest/googletest/include', - } + project 'gtest_main' + kind 'StaticLib' + language 'C++' + uuid(os.uuid('gtest_main')) + files 'googletest/googletest/src/gtest_main.cc' + includedirs { + 'googletest/googletest', + 'googletest/googletest/include', + } diff --git a/JSImpl/test/gmock.vcxproj b/JSImpl/test/gmock.vcxproj index 8fbaa69..f4e2bec 100644 --- a/JSImpl/test/gmock.vcxproj +++ b/JSImpl/test/gmock.vcxproj @@ -21,11 +21,13 @@ <ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
+ <PreferredToolArchitecture>x64</PreferredToolArchitecture>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
+ <PreferredToolArchitecture>x64</PreferredToolArchitecture>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
@@ -114,17 +116,17 @@ </Link>
</ItemDefinitionGroup>
<ItemGroup>
- <ClInclude Include="googletest\googlemock\include\gmock\gmock-spec-builders.h" />
- <ClInclude Include="googletest\googlemock\include\gmock\gmock.h" />
<ClInclude Include="googletest\googlemock\include\gmock\gmock-actions.h" />
- <ClInclude Include="googletest\googlemock\include\gmock\gmock-generated-matchers.h" />
+ <ClInclude Include="googletest\googlemock\include\gmock\gmock-cardinalities.h" />
<ClInclude Include="googletest\googlemock\include\gmock\gmock-generated-actions.h" />
- <ClInclude Include="googletest\googlemock\include\gmock\gmock-more-matchers.h" />
<ClInclude Include="googletest\googlemock\include\gmock\gmock-generated-function-mockers.h" />
- <ClInclude Include="googletest\googlemock\include\gmock\gmock-cardinalities.h" />
+ <ClInclude Include="googletest\googlemock\include\gmock\gmock-generated-matchers.h" />
<ClInclude Include="googletest\googlemock\include\gmock\gmock-generated-nice-strict.h" />
- <ClInclude Include="googletest\googlemock\include\gmock\gmock-more-actions.h" />
<ClInclude Include="googletest\googlemock\include\gmock\gmock-matchers.h" />
+ <ClInclude Include="googletest\googlemock\include\gmock\gmock-more-actions.h" />
+ <ClInclude Include="googletest\googlemock\include\gmock\gmock-more-matchers.h" />
+ <ClInclude Include="googletest\googlemock\include\gmock\gmock-spec-builders.h" />
+ <ClInclude Include="googletest\googlemock\include\gmock\gmock.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="googletest\googlemock\src\gmock-all.cc">
diff --git a/JSImpl/test/gmock.vcxproj.filters b/JSImpl/test/gmock.vcxproj.filters index 01914f2..7ecdd12 100644 --- a/JSImpl/test/gmock.vcxproj.filters +++ b/JSImpl/test/gmock.vcxproj.filters @@ -18,37 +18,37 @@ </Filter>
</ItemGroup>
<ItemGroup>
- <ClInclude Include="googletest\googlemock\include\gmock\gmock-spec-builders.h">
+ <ClInclude Include="googletest\googlemock\include\gmock\gmock-actions.h">
<Filter>googletest\googlemock\include\gmock</Filter>
</ClInclude>
- <ClInclude Include="googletest\googlemock\include\gmock\gmock.h">
+ <ClInclude Include="googletest\googlemock\include\gmock\gmock-cardinalities.h">
<Filter>googletest\googlemock\include\gmock</Filter>
</ClInclude>
- <ClInclude Include="googletest\googlemock\include\gmock\gmock-actions.h">
+ <ClInclude Include="googletest\googlemock\include\gmock\gmock-generated-actions.h">
<Filter>googletest\googlemock\include\gmock</Filter>
</ClInclude>
- <ClInclude Include="googletest\googlemock\include\gmock\gmock-generated-matchers.h">
+ <ClInclude Include="googletest\googlemock\include\gmock\gmock-generated-function-mockers.h">
<Filter>googletest\googlemock\include\gmock</Filter>
</ClInclude>
- <ClInclude Include="googletest\googlemock\include\gmock\gmock-generated-actions.h">
+ <ClInclude Include="googletest\googlemock\include\gmock\gmock-generated-matchers.h">
<Filter>googletest\googlemock\include\gmock</Filter>
</ClInclude>
- <ClInclude Include="googletest\googlemock\include\gmock\gmock-more-matchers.h">
+ <ClInclude Include="googletest\googlemock\include\gmock\gmock-generated-nice-strict.h">
<Filter>googletest\googlemock\include\gmock</Filter>
</ClInclude>
- <ClInclude Include="googletest\googlemock\include\gmock\gmock-generated-function-mockers.h">
+ <ClInclude Include="googletest\googlemock\include\gmock\gmock-matchers.h">
<Filter>googletest\googlemock\include\gmock</Filter>
</ClInclude>
- <ClInclude Include="googletest\googlemock\include\gmock\gmock-cardinalities.h">
+ <ClInclude Include="googletest\googlemock\include\gmock\gmock-more-actions.h">
<Filter>googletest\googlemock\include\gmock</Filter>
</ClInclude>
- <ClInclude Include="googletest\googlemock\include\gmock\gmock-generated-nice-strict.h">
+ <ClInclude Include="googletest\googlemock\include\gmock\gmock-more-matchers.h">
<Filter>googletest\googlemock\include\gmock</Filter>
</ClInclude>
- <ClInclude Include="googletest\googlemock\include\gmock\gmock-more-actions.h">
+ <ClInclude Include="googletest\googlemock\include\gmock\gmock-spec-builders.h">
<Filter>googletest\googlemock\include\gmock</Filter>
</ClInclude>
- <ClInclude Include="googletest\googlemock\include\gmock\gmock-matchers.h">
+ <ClInclude Include="googletest\googlemock\include\gmock\gmock.h">
<Filter>googletest\googlemock\include\gmock</Filter>
</ClInclude>
</ItemGroup>
diff --git a/JSImpl/test/gtest.vcxproj b/JSImpl/test/gtest.vcxproj index 623e8f5..7adfade 100644 --- a/JSImpl/test/gtest.vcxproj +++ b/JSImpl/test/gtest.vcxproj @@ -21,11 +21,13 @@ <ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
+ <PreferredToolArchitecture>x64</PreferredToolArchitecture>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
+ <PreferredToolArchitecture>x64</PreferredToolArchitecture>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
@@ -114,16 +116,16 @@ </Link>
</ItemDefinitionGroup>
<ItemGroup>
- <ClInclude Include="googletest\googletest\include\gtest\gtest_prod.h" />
+ <ClInclude Include="googletest\googletest\include\gtest\gtest-death-test.h" />
<ClInclude Include="googletest\googletest\include\gtest\gtest-message.h" />
<ClInclude Include="googletest\googletest\include\gtest\gtest-param-test.h" />
- <ClInclude Include="googletest\googletest\include\gtest\gtest-test-part.h" />
<ClInclude Include="googletest\googletest\include\gtest\gtest-printers.h" />
- <ClInclude Include="googletest\googletest\include\gtest\gtest-typed-test.h" />
<ClInclude Include="googletest\googletest\include\gtest\gtest-spi.h" />
- <ClInclude Include="googletest\googletest\include\gtest\gtest_pred_impl.h" />
+ <ClInclude Include="googletest\googletest\include\gtest\gtest-test-part.h" />
+ <ClInclude Include="googletest\googletest\include\gtest\gtest-typed-test.h" />
<ClInclude Include="googletest\googletest\include\gtest\gtest.h" />
- <ClInclude Include="googletest\googletest\include\gtest\gtest-death-test.h" />
+ <ClInclude Include="googletest\googletest\include\gtest\gtest_pred_impl.h" />
+ <ClInclude Include="googletest\googletest\include\gtest\gtest_prod.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="googletest\googletest\src\gtest-all.cc">
diff --git a/JSImpl/test/gtest.vcxproj.filters b/JSImpl/test/gtest.vcxproj.filters index 780060b..3a35c75 100644 --- a/JSImpl/test/gtest.vcxproj.filters +++ b/JSImpl/test/gtest.vcxproj.filters @@ -18,7 +18,7 @@ </Filter>
</ItemGroup>
<ItemGroup>
- <ClInclude Include="googletest\googletest\include\gtest\gtest_prod.h">
+ <ClInclude Include="googletest\googletest\include\gtest\gtest-death-test.h">
<Filter>googletest\googletest\include\gtest</Filter>
</ClInclude>
<ClInclude Include="googletest\googletest\include\gtest\gtest-message.h">
@@ -27,25 +27,25 @@ <ClInclude Include="googletest\googletest\include\gtest\gtest-param-test.h">
<Filter>googletest\googletest\include\gtest</Filter>
</ClInclude>
- <ClInclude Include="googletest\googletest\include\gtest\gtest-test-part.h">
- <Filter>googletest\googletest\include\gtest</Filter>
- </ClInclude>
<ClInclude Include="googletest\googletest\include\gtest\gtest-printers.h">
<Filter>googletest\googletest\include\gtest</Filter>
</ClInclude>
- <ClInclude Include="googletest\googletest\include\gtest\gtest-typed-test.h">
+ <ClInclude Include="googletest\googletest\include\gtest\gtest-spi.h">
<Filter>googletest\googletest\include\gtest</Filter>
</ClInclude>
- <ClInclude Include="googletest\googletest\include\gtest\gtest-spi.h">
+ <ClInclude Include="googletest\googletest\include\gtest\gtest-test-part.h">
<Filter>googletest\googletest\include\gtest</Filter>
</ClInclude>
- <ClInclude Include="googletest\googletest\include\gtest\gtest_pred_impl.h">
+ <ClInclude Include="googletest\googletest\include\gtest\gtest-typed-test.h">
<Filter>googletest\googletest\include\gtest</Filter>
</ClInclude>
<ClInclude Include="googletest\googletest\include\gtest\gtest.h">
<Filter>googletest\googletest\include\gtest</Filter>
</ClInclude>
- <ClInclude Include="googletest\googletest\include\gtest\gtest-death-test.h">
+ <ClInclude Include="googletest\googletest\include\gtest\gtest_pred_impl.h">
+ <Filter>googletest\googletest\include\gtest</Filter>
+ </ClInclude>
+ <ClInclude Include="googletest\googletest\include\gtest\gtest_prod.h">
<Filter>googletest\googletest\include\gtest</Filter>
</ClInclude>
</ItemGroup>
diff --git a/JSImpl/test/gtest_main.vcxproj b/JSImpl/test/gtest_main.vcxproj index 997d941..2ce7ce4 100644 --- a/JSImpl/test/gtest_main.vcxproj +++ b/JSImpl/test/gtest_main.vcxproj @@ -21,11 +21,13 @@ <ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
+ <PreferredToolArchitecture>x64</PreferredToolArchitecture>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
+ <PreferredToolArchitecture>x64</PreferredToolArchitecture>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
diff --git a/JSImpl/test/sprtTests.cpp b/JSImpl/test/sprtTests.cpp index 7621ca3..eef7147 100644 --- a/JSImpl/test/sprtTests.cpp +++ b/JSImpl/test/sprtTests.cpp @@ -1,6 +1,7 @@ #include <gtest/gtest.h> #include <spasm.hpp> +#include <assembler.hpp> #include <sstream> using Spasm::OpCodes; @@ -9,12 +10,12 @@ struct SPRTTest : public ::testing::Test { typedef std::vector<Spasm::byte> ByteCode; - void Run(ByteCode& code) + void Run(const ByteCode& code) { Run(code.data(), code.size()); } - void Run(Spasm::byte* bytecode, size_t size) + void Run(const Spasm::byte* bytecode, size_t size) { VM.Initialize(size, bytecode, Input, Output); ASSERT_EQ(Spasm::Spasm::RunResult::Success, VM.run()); @@ -27,6 +28,19 @@ struct SPRTTest : public ::testing::Test std::ostringstream Output; }; +struct SPASMTest : public SPRTTest +{ + void CompileAndRun(const std::string& program) + { + SpasmImpl::ASM::Bytecode_Memory bytecode; + std::istringstream programInput; + programInput.str(program); + ASSERT_TRUE(SpasmImpl::ASM::compile(programInput, bytecode)) + << "Could not compile the program:" << std::endl << program; + Run(bytecode.bytecode()); + } +}; + TEST_F(SPRTTest, Empty) { } @@ -184,22 +198,22 @@ TEST_F(SPRTTest, JumpFalse) TEST_F(SPRTTest, Call) { Spasm::byte bytecode[] = { - OpCodes::Alloc, 5, // 2 + OpCodes::Push, 5, // 2 OpCodes::Const, 1, 0, // 5 OpCodes::Const, 2, 6, // 8 OpCodes::Const, 3, 7, // 11 OpCodes::Const, 4, 2, // 14 - OpCodes::Push, 3, // 16 - OpCodes::Push, 2, // 18 - OpCodes::Push, 4, // 20 + OpCodes::PushFrom, 3, // 16 + OpCodes::PushFrom, 2, // 18 + OpCodes::PushFrom, 4, // 20 OpCodes::Call, 25, // 22 OpCodes::Print, 4, // 24 - OpCodes::Halt, // 25 + OpCodes::Halt, // 25 OpCodes::Print, 0, // 27 OpCodes::Print, -1, // 29 OpCodes::Print, -2, // 31 OpCodes::Mul, 1, -2, -1,// 33 - OpCodes::Ret, 1, // 35 + OpCodes::Ret, 1, // 35 }; Run(bytecode, sizeof(bytecode)); @@ -218,3 +232,81 @@ TEST_F(SPRTTest, Read) ASSERT_EQ(Output.str(), "42"); } +TEST_F(SPASMTest, RSyntax) +{ + const char* program = + "push 5" "\n" + "const r1 0" "\n" + "const r2 6" "\n" + "const r3 7" "\n" + "const r4 2" "\n" + "pushr r3" "\n" + "pushr r2" "\n" + "pushr r4" "\n" + "call mult" "\n" + "popr r1" "\n" + "print r1" "\n" + "halt" "\n" + "label mult" "\n" + "print a0" "\n" + "print a1" "\n" + "print a2" "\n" + "mul r1 a2 a1" "\n" + "ret r1" "\n" + "" + ; + CompileAndRun(program); + ASSERT_EQ(Output.str(), "26742"); +} + +TEST_F(SPASMTest, Call) +{ + const char* program = + "push 5" "\n" + "const 1 0" "\n" + "const 2 6" "\n" + "const 3 7" "\n" + "const 4 2" "\n" + "pushr 3" "\n" + "pushr 2" "\n" + "pushr 4" "\n" + "call mult" "\n" + "print 4" "\n" + "halt" "\n" + "label mult" "\n" + "print 0" "\n" + "print -1" "\n" + "print -2" "\n" + "mul 1 -2 -1" "\n" + "ret 1" "\n" + "" + ; + CompileAndRun(program); + ASSERT_EQ(Output.str(), "26742"); +} + +TEST_F(SPASMTest, GCD) +{ + const char* program = + "push 3" "\n" + "read 1" "\n" + "read 2" "\n" + "label loop" "\n" + "less 3 1 2" "\n" + "jmpt 3 sub_ba" "\n" + "less 3 2 1" "\n" + "jmpt 3 sub_ab" "\n" + "print 1" "\n" + "halt" "\n" + "label sub_ab" "\n" + "sub 1 1 2" "\n" + "jmp loop" "\n" + "label sub_ba" "\n" + "sub 2 2 1" "\n" + "jmp loop" "\n" + "" + ; + Input.str("21 12"); + CompileAndRun(program); + ASSERT_EQ(Output.str(), "3"); +} |
