#!/usr/bin/perl -w
use strict;
use warnings;
use PerlRPG::Console;
use PerlRPG::Script;


use Test::More;

$PerlRPG::Console::LogLevel = ERROR;
ok( !GetGameVar("TestVar"),				"Undefined GetGameVar should fail");
ok( !SetGameVar("TestVar"),				"Undefined SetGameVar should fail");
$PerlRPG::Console::LogLevel = WARN;
DefGameVar('TestVar', 1);
ok( GetGameVar("TestVar") == 1,				"Defined GetGameVar should be 1");
ok( SetGameVar("TestVar", 2) == 2,			"Defined SetGameVar(2) should be 2");
DefGameVar('TestVar', 1);
ok( SetGameVar("TestVar", 2) == 2,			"Redefined GameVar=1 should still be 2");

PerlRPG::Script::RunScriptLine("test", 1, "TestVar = TestVar + 1");
ok( GetGameVar("TestVar")==3,				"RunScriptLine sets TestVar to 3");

ok( PerlRPG::Script::IsString("\"foo\""),		"'\"foo\"' is a string");
ok( PerlRPG::Script::IsString("foo")==0,		"'foo' is not a string");
ok( PerlRPG::Script::IsString(5)==0,			"'5' is not a string");
ok( EvalString("\"[TestVar]\"") eq '3',			"\"[TestVar]\" is 3");
ok( EvalString("3 + 3") == 6,				"\"3 + 3\" == 6");
ok( EvalString("lc('FoO') . uc('FoO')") eq 'fooFOO',	"String function test");

done_testing();
