Internal Test: Verifies that a rule defined in a nested LocalTransformer correctly resolves its parent to the root uCalc instance.
ID: 999
See: uCalc = [uCalc]
using uCalcSoftware;
var uc = new uCalc();
var root_uc = new uCalc();
root_uc.Description = "Root uCalc Instance";
var main_t = new uCalc.Transformer(root_uc);
// Create a rule in the main transformer
var outerRule = main_t.Pattern("OUTER({body})");
// Get a local transformer for the outer rule
var local_t = outerRule.LocalTransformer;
local_t.Description = "Local Transformer";
// Create an inner rule inside the local transformer
var innerRule = local_t.FromTo("INNER", "inner_match");
// Verify both rules resolve to the same root uCalc instance
var outerParent = outerRule.uCalc;
var innerParent = innerRule.uCalc;
Console.WriteLine($"Outer rule's parent: {outerParent.Description}");
Console.WriteLine($"Inner rule's parent: {innerParent.Description}");
Console.WriteLine($"Both rules share the same root uCalc instance: {outerParent.Handle() == innerParent.Handle()}");
Outer rule's parent: Root uCalc Instance
Inner rule's parent: Root uCalc Instance
Both rules share the same root uCalc instance: True using uCalcSoftware; var uc = new uCalc(); var root_uc = new uCalc(); root_uc.Description = "Root uCalc Instance"; var main_t = new uCalc.Transformer(root_uc); // Create a rule in the main transformer var outerRule = main_t.Pattern("OUTER({body})"); // Get a local transformer for the outer rule var local_t = outerRule.LocalTransformer; local_t.Description = "Local Transformer"; // Create an inner rule inside the local transformer var innerRule = local_t.FromTo("INNER", "inner_match"); // Verify both rules resolve to the same root uCalc instance var outerParent = outerRule.uCalc; var innerParent = innerRule.uCalc; Console.WriteLine($"Outer rule's parent: {outerParent.Description}"); Console.WriteLine($"Inner rule's parent: {innerParent.Description}"); Console.WriteLine($"Both rules share the same root uCalc instance: {outerParent.Handle() == innerParent.Handle()}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
#define tf(IsTrue) ((IsTrue) ? "True" : "False")
int main() {
uCalc uc;
uCalc root_uc;
root_uc.Description("Root uCalc Instance");
uCalc::Transformer main_t(root_uc);
// Create a rule in the main transformer
auto outerRule = main_t.Pattern("OUTER({body})");
// Get a local transformer for the outer rule
auto local_t = outerRule.LocalTransformer();
local_t.Description("Local Transformer");
// Create an inner rule inside the local transformer
auto innerRule = local_t.FromTo("INNER", "inner_match");
// Verify both rules resolve to the same root uCalc instance
auto outerParent = outerRule.uCalc();
auto innerParent = innerRule.uCalc();
cout << "Outer rule's parent: " << outerParent.Description() << endl;
cout << "Inner rule's parent: " << innerParent.Description() << endl;
cout << "Both rules share the same root uCalc instance: " << tf(outerParent.Handle() == innerParent.Handle()) << endl;
}
Outer rule's parent: Root uCalc Instance
Inner rule's parent: Root uCalc Instance
Both rules share the same root uCalc instance: True #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; #define tf(IsTrue) ((IsTrue) ? "True" : "False") int main() { uCalc uc; uCalc root_uc; root_uc.Description("Root uCalc Instance"); uCalc::Transformer main_t(root_uc); // Create a rule in the main transformer auto outerRule = main_t.Pattern("OUTER({body})"); // Get a local transformer for the outer rule auto local_t = outerRule.LocalTransformer(); local_t.Description("Local Transformer"); // Create an inner rule inside the local transformer auto innerRule = local_t.FromTo("INNER", "inner_match"); // Verify both rules resolve to the same root uCalc instance auto outerParent = outerRule.uCalc(); auto innerParent = innerRule.uCalc(); cout << "Outer rule's parent: " << outerParent.Description() << endl; cout << "Inner rule's parent: " << innerParent.Description() << endl; cout << "Both rules share the same root uCalc instance: " << tf(outerParent.Handle() == innerParent.Handle()) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim root_uc As New uCalc()
root_uc.Description = "Root uCalc Instance"
Dim main_t As New uCalc.Transformer(root_uc)
'// Create a rule in the main transformer
Dim outerRule = main_t.Pattern("OUTER({body})")
'// Get a local transformer for the outer rule
Dim local_t = outerRule.LocalTransformer
local_t.Description = "Local Transformer"
'// Create an inner rule inside the local transformer
Dim innerRule = local_t.FromTo("INNER", "inner_match")
'// Verify both rules resolve to the same root uCalc instance
Dim outerParent = outerRule.uCalc
Dim innerParent = innerRule.uCalc
Console.WriteLine($"Outer rule's parent: {outerParent.Description}")
Console.WriteLine($"Inner rule's parent: {innerParent.Description}")
Console.WriteLine($"Both rules share the same root uCalc instance: {outerParent.Handle() = innerParent.Handle()}")
End Sub
End Module
Outer rule's parent: Root uCalc Instance
Inner rule's parent: Root uCalc Instance
Both rules share the same root uCalc instance: True Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim root_uc As New uCalc() root_uc.Description = "Root uCalc Instance" Dim main_t As New uCalc.Transformer(root_uc) '// Create a rule in the main transformer Dim outerRule = main_t.Pattern("OUTER({body})") '// Get a local transformer for the outer rule Dim local_t = outerRule.LocalTransformer local_t.Description = "Local Transformer" '// Create an inner rule inside the local transformer Dim innerRule = local_t.FromTo("INNER", "inner_match") '// Verify both rules resolve to the same root uCalc instance Dim outerParent = outerRule.uCalc Dim innerParent = innerRule.uCalc Console.WriteLine($"Outer rule's parent: {outerParent.Description}") Console.WriteLine($"Inner rule's parent: {innerParent.Description}") Console.WriteLine($"Both rules share the same root uCalc instance: {outerParent.Handle() = innerParent.Handle()}") End Sub End Module