Skip to content

Commit

Permalink
Forgot to add Const Bindings test
Browse files Browse the repository at this point in the history
git-svn-id: https://scrat.svn.sourceforge.net/svnroot/scrat/trunk@17 17df20b9-c460-4d53-a56e-632d1712e828
  • Loading branch information
toji committed Sep 23, 2009
1 parent 2067cf5 commit 4d68e6d
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions sqrattest/ConstBindings.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// Copyright (c) 2009 Brandon Jones
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//

#include <gtest/gtest.h>
#include <sqrat.h>
#include "Fixture.h"

using namespace Sqrat;

TEST_F(SqratTest, ConstBindings) {
DefaultVM::Set(vm);

ConstTable(vm).Enum(_SC("Color"), Enumeration(vm)
.Const(_SC("Black"), 0)
.Const(_SC("Red"), 1)
.Const(_SC("Green"), 2)
.Const(_SC("Blue"), 3)
);

ConstTable().Const(_SC("Version"), _SC("1.0.0"));

Script script;

try {
script.CompileString(_SC(" \
gTest.EXPECT_INT_EQ(Color.Black, 0); \
gTest.EXPECT_INT_EQ(Color.Red, 1); \
gTest.EXPECT_INT_EQ(Color.Green, 2); \
gTest.EXPECT_INT_EQ(Color.Blue, 3); \
gTest.EXPECT_STR_EQ(Version, \"1.0.0\"); \
"));
} catch(Exception ex) {
FAIL() << _SC("Compile Failed: ") << ex.Message();
}

try {
script.Run();
} catch(Exception ex) {
FAIL() << _SC("Run Failed: ") << ex.Message();
}
}

0 comments on commit 4d68e6d

Please sign in to comment.