Skip to content

Commit

Permalink
SQUASH LATER test CPP API
Browse files Browse the repository at this point in the history
  • Loading branch information
garfieldnate committed Aug 26, 2023
1 parent 09a3cfa commit 389818c
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 81 deletions.
62 changes: 61 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,67 @@
"type_traits": "cpp",
"iosfwd": "cpp",
"map": "cpp",
"stdexcept": "cpp"
"stdexcept": "cpp",
"__bit_reference": "cpp",
"__bits": "cpp",
"__errc": "cpp",
"__locale": "cpp",
"__mutex_base": "cpp",
"__node_handle": "cpp",
"__split_buffer": "cpp",
"__threading_support": "cpp",
"__tuple": "cpp",
"__verbose_abort": "cpp",
"array": "cpp",
"bit": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"cinttypes": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"complex": "cpp",
"condition_variable": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"ios": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"list": "cpp",
"locale": "cpp",
"memory": "cpp",
"mutex": "cpp",
"new": "cpp",
"ostream": "cpp",
"queue": "cpp",
"ratio": "cpp",
"set": "cpp",
"sstream": "cpp",
"stack": "cpp",
"streambuf": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"thread": "cpp",
"typeinfo": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"__nullptr": "cpp",
"chrono": "cpp",
"compare": "cpp",
"concepts": "cpp",
"algorithm": "cpp"
},
"openInGitHub.defaultBranch": "development",
}
1 change: 1 addition & 0 deletions Core/ClientSML/src/sml_ClientKernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2077,6 +2077,7 @@ int Kernel::InternalAddRhsFunction(smlRhsEventId id, char const* pRhsFunctionNam
bool found = m_RhsEventMap.findFirstValueByTest(&test, &optionalFoundHandler) ;
if (found && optionalFoundHandler.m_Handler != 0)
{
// TODO: log a warning here to help catch copy/paste errors in the client
return optionalFoundHandler.getCallbackID() ;
}

Expand Down
11 changes: 10 additions & 1 deletion UnitTests/SoarTestAgents/FullTests/testsml.soar
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,22 @@ sp {apply*move
(<ol> ^move <m> ^alternative <m> ^A <m>)
(<m> ^row <row> ^col <col>)}

sp {apply*user*exec*cpp
(state <s> ^operator <o> ^io.output-link <ol>)
(<o> ^name move ^space <sp>)
(<sp> ^row <row> ^col <col>)
-->
(<ol> ^test (exec test-rhs-cpp | hello | <row> | "ABC DEF" world!|))
}

sp {apply*user*exec
(state <s> ^operator <o> ^io.output-link <ol>)
(<o> ^name move ^space <sp>)
(<sp> ^row <row> ^col <col>)
-->
# use a long string to test the buffer re-allocation logic
(<ol> ^test (exec test-rhs | hello | <row> | "ABC DEF" world!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!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!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |))
}

sp {apply*user*cmd
(state <s> ^operator <o> ^io.output-link <ol>)
Expand Down
7 changes: 6 additions & 1 deletion UnitTests/SoarUnitTests/FullTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include "sml_ClientKernel.h"
#include "soar_instance.h"

#include <functional>

bool g_Cancel = false;

#ifdef _WIN32
Expand Down Expand Up @@ -376,9 +378,11 @@ void FullTests_Parent::testRHSHandler()
int callback_rhs1 = m_pKernel->AddRhsFunction("test-rhs", Handlers::MyRhsFunctionHandler, &rhsFunctionHandlerReceived) ;
int callback_rhs_dup = m_pKernel->AddRhsFunction("test-rhs", Handlers::MyRhsFunctionHandler, &rhsFunctionHandlerReceived) ;
//agent->RegisterForPrintEvent( sml::smlEVENT_PRINT, Handlers::DebugPrintEventHandler, 0) ;

no_agent_assertTrue_msg("Duplicate RHS function registration should be detected and be ignored", callback_rhs_dup == callback_rhs1);

bool cppRhsHandlerReceived(false);
int callback_rhs_cpp = m_pKernel->AddRhsFunctionCPP("test-rhs-cpp", Handlers::GetRhsFunctionHandlerCPP(&cppRhsHandlerReceived)) ;

// need this to fire production that calls test-rhs
sml::Identifier* pSquare = agent->GetInputLink()->CreateIdWME("square") ;
no_agent_assertTrue(pSquare);
Expand All @@ -396,6 +400,7 @@ void FullTests_Parent::testRHSHandler()
//std::cout << agent->ExecuteCommandLine("p i2 --depth 4") << std::endl;

no_agent_assertTrue(rhsFunctionHandlerReceived);
no_agent_assertTrue(cppRhsHandlerReceived);

no_agent_assertTrue(m_pKernel->RemoveRhsFunction(callback_rhs1));

Expand Down
Loading

0 comments on commit 389818c

Please sign in to comment.