File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 11// SPDX-License-Identifier: Apache-2.0
22
3+ #include < scratchcpp/iengine.h>
4+ #include < scratchcpp/dev/compiler.h>
5+
36#include " customblocks.h"
47
58using namespace libscratchcpp ;
@@ -16,4 +19,5 @@ std::string CustomBlocks::description() const
1619
1720void CustomBlocks::registerBlocks (IEngine *engine)
1821{
22+ engine->addCompileFunction (this , " procedures_definition" , [](Compiler *) -> CompilerValue * { return nullptr ; });
1923}
Original file line number Diff line number Diff line change 1+ #include < scratchcpp/project.h>
2+ #include < scratchcpp/dev/test/scriptbuilder.h>
3+ #include < scratchcpp/dev/compiler.h>
4+ #include < scratchcpp/sprite.h>
15#include < enginemock.h>
26
37#include " ../common.h"
48#include " dev/blocks/customblocks.h"
59
610using namespace libscratchcpp ;
11+ using namespace libscratchcpp ::test;
712
813class CustomBlocksTest : public testing ::Test
914{
1015 public:
11- void SetUp () override { m_extension = std::make_unique<CustomBlocks>(); }
16+ void SetUp () override
17+ {
18+ m_extension = std::make_unique<CustomBlocks>();
19+ m_engine = m_project.engine ().get ();
20+ m_extension->registerBlocks (m_engine);
21+ }
1222
1323 std::unique_ptr<IExtension> m_extension;
24+ Project m_project;
25+ IEngine *m_engine = nullptr ;
1426 EngineMock m_engineMock;
1527};
28+
29+ TEST_F (CustomBlocksTest, Definition)
30+ {
31+ auto target = std::make_shared<Sprite>();
32+ ScriptBuilder builder (m_extension.get (), m_engine, target);
33+
34+ builder.addBlock (" procedures_definition" );
35+ auto block = builder.currentBlock ();
36+
37+ Compiler compiler (&m_engineMock, target.get ());
38+ compiler.compile (block);
39+ ASSERT_TRUE (compiler.unsupportedBlocks ().empty ());
40+ }
You can’t perform that action at this time.
0 commit comments