Skip to content

Commit

Permalink
BlockPrototype: Add support for %n args
Browse files Browse the repository at this point in the history
Resolves: #616
  • Loading branch information
adazem009 committed Jan 4, 2025
1 parent ba66d94 commit ce875ee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/scratch/blockprototype_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ void BlockPrototypePrivate::setProcCode(const std::string &newProcCode)
arg = false;
switch (c) {
case 's':
case 'n':
argumentDefaults.push_back("");
argumentTypes.push_back(BlockPrototype::ArgType::StringNum);
break;
Expand Down
7 changes: 4 additions & 3 deletions test/scratch_classes/blockprototype_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ TEST(BlockPrototypeTest, Constructors)
ASSERT_TRUE(p2.argumentDefaults().empty());
ASSERT_FALSE(p2.warp());

BlockPrototype p3("test %s block %s %b");
ASSERT_EQ(p3.procCode(), "test %s block %s %b");
BlockPrototype p3("test %s block %s %b test %n");
ASSERT_EQ(p3.procCode(), "test %s block %s %b test %n");
ASSERT_EQ(
p3.argumentTypes(),
std::vector<BlockPrototype::ArgType>({
BlockPrototype::ArgType::StringNum,
BlockPrototype::ArgType::StringNum,
BlockPrototype::ArgType::Bool,
BlockPrototype::ArgType::StringNum,
}));
ASSERT_EQ(p3.argumentDefaults(), std::vector<Value>({ "", "", false }));
ASSERT_EQ(p3.argumentDefaults(), std::vector<Value>({ "", "", false, "" }));
ASSERT_FALSE(p3.warp());
}

Expand Down

0 comments on commit ce875ee

Please sign in to comment.