Internal Test: Verifies that the correct parent is returned when using a nested LocalTransformer, confirming hierarchical integrity.
ID: 962
using uCalcSoftware;
var uc = new uCalc();
var main_t = new uCalc.Transformer();
main_t.Description = "Main Transformer";
// Create an outer 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 the parent of the outer rule is the main transformer
Console.WriteLine($"Outer rule's parent: {outerRule.ParentTransformer.Description}");
// Verify the parent of the inner rule is the local transformer
Console.WriteLine($"Inner rule's parent: {innerRule.ParentTransformer.Description}");
Outer rule's parent: Main Transformer
Inner rule's parent: Local Transformer using uCalcSoftware; var uc = new uCalc(); var main_t = new uCalc.Transformer(); main_t.Description = "Main Transformer"; // Create an outer 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 the parent of the outer rule is the main transformer Console.WriteLine($"Outer rule's parent: {outerRule.ParentTransformer.Description}"); // Verify the parent of the inner rule is the local transformer Console.WriteLine($"Inner rule's parent: {innerRule.ParentTransformer.Description}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uCalc::Transformer main_t;
main_t.Description("Main Transformer");
// Create an outer 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 the parent of the outer rule is the main transformer
cout << "Outer rule's parent: " << outerRule.ParentTransformer().Description() << endl;
// Verify the parent of the inner rule is the local transformer
cout << "Inner rule's parent: " << innerRule.ParentTransformer().Description() << endl;
}
Outer rule's parent: Main Transformer
Inner rule's parent: Local Transformer #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uCalc::Transformer main_t; main_t.Description("Main Transformer"); // Create an outer 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 the parent of the outer rule is the main transformer cout << "Outer rule's parent: " << outerRule.ParentTransformer().Description() << endl; // Verify the parent of the inner rule is the local transformer cout << "Inner rule's parent: " << innerRule.ParentTransformer().Description() << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim main_t As New uCalc.Transformer()
main_t.Description = "Main Transformer"
'// Create an outer 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 the parent of the outer rule is the main transformer
Console.WriteLine($"Outer rule's parent: {outerRule.ParentTransformer.Description}")
'// Verify the parent of the inner rule is the local transformer
Console.WriteLine($"Inner rule's parent: {innerRule.ParentTransformer.Description}")
End Sub
End Module
Outer rule's parent: Main Transformer
Inner rule's parent: Local Transformer Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim main_t As New uCalc.Transformer() main_t.Description = "Main Transformer" '// Create an outer 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 the parent of the outer rule is the main transformer Console.WriteLine($"Outer rule's parent: {outerRule.ParentTransformer.Description}") '// Verify the parent of the inner rule is the local transformer Console.WriteLine($"Inner rule's parent: {innerRule.ParentTransformer.Description}") End Sub End Module