Skip to content

Commit

Permalink
Adapting to latest Anyness changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Epixu committed Aug 26, 2024
1 parent 49bba40 commit 9595e9b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
2 changes: 2 additions & 0 deletions source/Code.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "verbs/Catenate.inl"
#include "verbs/Conjunct.inl"
#include "verbs/Interpret.inl"
#include "verbs/Compare.inl"

LANGULUS_RTTI_BOUNDARY(RTTI::MainBoundary)

Expand Down Expand Up @@ -89,6 +90,7 @@ namespace Langulus::Flow
(void)MetaOf<Verbs::Catenate>();
(void)MetaOf<Verbs::Conjunct>();
(void)MetaOf<Verbs::Interpret>();
(void)MetaOf<Verbs::Compare>();

// Parse
Many output;
Expand Down
2 changes: 1 addition & 1 deletion source/Resolvable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace Langulus::Flow
/// @return the static memory block representing this instance
Block<> Resolvable::GetBlock() const noexcept {
return {
DataState::Static, mClassType, 1,
DataState::Default, mClassType, 1,
const_cast<void*>(mClassPointer)
};
}
Expand Down
4 changes: 2 additions & 2 deletions source/inner/Missing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ bool Missing::Push(const Many& content) {
// Let's check if there's a filter
if (not mFilter) {
// No filter, just push
if (not content.template CastsTo<Verb, true>()) {
/*if (not content.template CastsTo<Verb, true>()) {
// Always try interpreting scope as verbs
Verbs::InterpretAs<Verb> interpreter;
interpreter.ShortCircuit(false);
Expand All @@ -144,7 +144,7 @@ bool Missing::Push(const Many& content) {
interpreter.GetOutput(), NoPriority);
return Push(compiled);
}
}
}*/

// Scope is either verbs or something else, just push
Many linked;
Expand Down
2 changes: 1 addition & 1 deletion source/verbs/Do.inl
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ namespace Langulus::Flow
// Iterate elements in the current context
for (Count i = 0; i < context.GetCount(); ++i) {
//verb.SetSource(context.GetElement(i));
Many ith = context.GetElement(i);
auto ith = context.GetElement(i);
if constexpr (RESOLVE)
ith = ith.GetResolved();
else
Expand Down
42 changes: 20 additions & 22 deletions test/TestFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ SCENARIO("Test factories", "[factory]") {
GIVEN("A factory with default usage") {
TFactory<Producible> factory;

WHEN("Default-constructed") {
REQUIRE(factory.IsUnique == false);
REQUIRE(factory.GetReusable() == nullptr);
REQUIRE(not factory.GetHashmap());
REQUIRE(factory.IsEmpty());
REQUIRE(factory.GetType() == MetaOf<Producible>());
}
REQUIRE(factory.IsUnique == false);
REQUIRE(factory.GetReusable() == nullptr);
REQUIRE(not factory.GetHashmap());
REQUIRE(factory.IsEmpty());
REQUIRE(factory.GetType() == MetaOf<Producible>());

WHEN("Two default elements produced") {
const auto descriptor = Construct::From<Producible>();
Expand All @@ -39,7 +37,7 @@ SCENARIO("Test factories", "[factory]") {
REQUIRE(creator.IsDone());
REQUIRE(out1.GetCount() == 1);
REQUIRE(out1.IsExact<Producible*>());
REQUIRE(out1.As<Producible*>()->Reference(0) == 2);
REQUIRE(out1.As<Producible*>()->Reference(0) == 3);
REQUIRE(out1.IsSparse());

creator.Undo();
Expand All @@ -49,7 +47,7 @@ SCENARIO("Test factories", "[factory]") {
auto out2 = creator.GetOutput();
REQUIRE(out2.GetCount() == 1);
REQUIRE(out2.IsExact<Producible*>());
REQUIRE(out2.As<Producible*>()->Reference(0) == 2);
REQUIRE(out2.As<Producible*>()->Reference(0) == 3);
REQUIRE(out2.IsSparse());

REQUIRE(factory.GetReusable() == factory.GetFrames()[0].GetRaw() + 2);
Expand All @@ -75,13 +73,11 @@ SCENARIO("Test factories", "[factory]") {
GIVEN("A factory with unique usage") {
TFactoryUnique<Producible> factory;

WHEN("Default-constructed") {
REQUIRE(factory.IsUnique == true);
REQUIRE(factory.GetReusable() == nullptr);
REQUIRE(not factory.GetHashmap());
REQUIRE(factory.IsEmpty());
REQUIRE(factory.GetType() == MetaOf<Producible>());
}
REQUIRE(factory.IsUnique == true);
REQUIRE(factory.GetReusable() == nullptr);
REQUIRE(not factory.GetHashmap());
REQUIRE(factory.IsEmpty());
REQUIRE(factory.GetType() == MetaOf<Producible>());

WHEN("Two default elements produced") {
const auto descriptor = Construct::From<Producible>();
Expand All @@ -100,7 +96,7 @@ SCENARIO("Test factories", "[factory]") {
REQUIRE(creator.IsDone());
REQUIRE(out1.GetCount() == 1);
REQUIRE(out1.IsExact<Producible*>());
REQUIRE(out1.As<Producible*>()->Reference(0) == 3);
REQUIRE(out1.As<Producible*>()->Reference(0) == 4);
REQUIRE(out1.IsSparse());
REQUIRE(out1 == out2);

Expand All @@ -117,24 +113,26 @@ SCENARIO("Test factories", "[factory]") {

prototype.Reference(-1);
}

WHEN("Two elements produced via descriptors") {
TMany<Producer> context;
context.New(1);

const auto descriptor = Construct::From<Producible>(
Traits::Parent(&context[0]));
Traits::Parent(&context[0]),
"test"_text
);
Verbs::Create creator {&descriptor};
const Producible prototype {&producer, descriptor.GetDescriptor()};

factory.Create(&producer, creator);
auto out1 = creator.GetOutput();
REQUIRE(out1.As<Producible*>()->Reference(0) == 2);
REQUIRE(out1.As<Producible*>()->Reference(0) == 3);

creator.Undo();
factory.Create(&producer, creator);
auto out2 = creator.GetOutput();
REQUIRE(out2.As<Producible*>()->Reference(0) == 3);
REQUIRE(out2.As<Producible*>()->Reference(0) == 4);

// Parent traits shouldn't participate in hashing
const auto hash = descriptor.GetDescriptor().GetHash();
Expand All @@ -144,7 +142,7 @@ SCENARIO("Test factories", "[factory]") {
REQUIRE(creator.IsDone());
REQUIRE(out1.GetCount() == 1);
REQUIRE(out1.IsExact<Producible*>());
REQUIRE(out1.As<Producible*>()->Reference(0) == 3);
REQUIRE(out1.As<Producible*>()->Reference(0) == 4);
REQUIRE(out1.IsSparse());
REQUIRE(out1 == out2);

Expand Down

0 comments on commit 9595e9b

Please sign in to comment.