Internal test to confirm instance isolation by proving a DataType is strictly bound to its parent uCalc instance.
ID: 562
See: uCalc = [uCalc]
using uCalcSoftware;
var uc = new uCalc();
// Create two completely separate uCalc instances.
var uc1 = new uCalc();
uc1.DefineVariable("x = 100");
var uc2 = new uCalc();
uc2.DefineVariable("x = 200");
// Get the DataType for 'Int' from the *first* instance.
var intType_from_uc1 = uc1.DataTypeOf("Int");
// Use the .uCalc() method to get the parent instance.
// This should be uc1, so evaluating 'x' should yield 100.
var parent = intType_from_uc1.uCalc;
Console.WriteLine($"Parent of intType_from_uc1 evaluates 'x' to: {parent.Eval("x")}");
// Get the DataType for 'Int' from the *second* instance.
var intType_from_uc2 = uc2.DataTypeOf("Int");
// This should be uc2, so evaluating 'x' should yield 200.
parent = intType_from_uc2.uCalc;
Console.WriteLine($"Parent of intType_from_uc2 evaluates 'x' to: {parent.Eval("x")}");
Parent of intType_from_uc1 evaluates 'x' to: 100
Parent of intType_from_uc2 evaluates 'x' to: 200 using uCalcSoftware; var uc = new uCalc(); // Create two completely separate uCalc instances. var uc1 = new uCalc(); uc1.DefineVariable("x = 100"); var uc2 = new uCalc(); uc2.DefineVariable("x = 200"); // Get the DataType for 'Int' from the *first* instance. var intType_from_uc1 = uc1.DataTypeOf("Int"); // Use the .uCalc() method to get the parent instance. // This should be uc1, so evaluating 'x' should yield 100. var parent = intType_from_uc1.uCalc; Console.WriteLine($"Parent of intType_from_uc1 evaluates 'x' to: {parent.Eval("x")}"); // Get the DataType for 'Int' from the *second* instance. var intType_from_uc2 = uc2.DataTypeOf("Int"); // This should be uc2, so evaluating 'x' should yield 200. parent = intType_from_uc2.uCalc; Console.WriteLine($"Parent of intType_from_uc2 evaluates 'x' to: {parent.Eval("x")}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
// Create two completely separate uCalc instances.
uCalc uc1;
uc1.DefineVariable("x = 100");
uCalc uc2;
uc2.DefineVariable("x = 200");
// Get the DataType for 'Int' from the *first* instance.
auto intType_from_uc1 = uc1.DataTypeOf("Int");
// Use the .uCalc() method to get the parent instance.
// This should be uc1, so evaluating 'x' should yield 100.
auto parent = intType_from_uc1.uCalc();
cout << "Parent of intType_from_uc1 evaluates 'x' to: " << parent.Eval("x") << endl;
// Get the DataType for 'Int' from the *second* instance.
auto intType_from_uc2 = uc2.DataTypeOf("Int");
// This should be uc2, so evaluating 'x' should yield 200.
parent = intType_from_uc2.uCalc();
cout << "Parent of intType_from_uc2 evaluates 'x' to: " << parent.Eval("x") << endl;
}
Parent of intType_from_uc1 evaluates 'x' to: 100
Parent of intType_from_uc2 evaluates 'x' to: 200 #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; // Create two completely separate uCalc instances. uCalc uc1; uc1.DefineVariable("x = 100"); uCalc uc2; uc2.DefineVariable("x = 200"); // Get the DataType for 'Int' from the *first* instance. auto intType_from_uc1 = uc1.DataTypeOf("Int"); // Use the .uCalc() method to get the parent instance. // This should be uc1, so evaluating 'x' should yield 100. auto parent = intType_from_uc1.uCalc(); cout << "Parent of intType_from_uc1 evaluates 'x' to: " << parent.Eval("x") << endl; // Get the DataType for 'Int' from the *second* instance. auto intType_from_uc2 = uc2.DataTypeOf("Int"); // This should be uc2, so evaluating 'x' should yield 200. parent = intType_from_uc2.uCalc(); cout << "Parent of intType_from_uc2 evaluates 'x' to: " << parent.Eval("x") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
'// Create two completely separate uCalc instances.
Dim uc1 As New uCalc()
uc1.DefineVariable("x = 100")
Dim uc2 As New uCalc()
uc2.DefineVariable("x = 200")
'// Get the DataType for 'Int' from the *first* instance.
Dim intType_from_uc1 = uc1.DataTypeOf("Int")
'// Use the .uCalc() method to get the parent instance.
'// This should be uc1, so evaluating 'x' should yield 100.
Dim parent = intType_from_uc1.uCalc
Console.WriteLine($"Parent of intType_from_uc1 evaluates 'x' to: {parent.Eval("x")}")
'// Get the DataType for 'Int' from the *second* instance.
Dim intType_from_uc2 = uc2.DataTypeOf("Int")
'// This should be uc2, so evaluating 'x' should yield 200.
parent = intType_from_uc2.uCalc
Console.WriteLine($"Parent of intType_from_uc2 evaluates 'x' to: {parent.Eval("x")}")
End Sub
End Module
Parent of intType_from_uc1 evaluates 'x' to: 100
Parent of intType_from_uc2 evaluates 'x' to: 200 Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() '// Create two completely separate uCalc instances. Dim uc1 As New uCalc() uc1.DefineVariable("x = 100") Dim uc2 As New uCalc() uc2.DefineVariable("x = 200") '// Get the DataType for 'Int' from the *first* instance. Dim intType_from_uc1 = uc1.DataTypeOf("Int") '// Use the .uCalc() method to get the parent instance. '// This should be uc1, so evaluating 'x' should yield 100. Dim parent = intType_from_uc1.uCalc Console.WriteLine($"Parent of intType_from_uc1 evaluates 'x' to: {parent.Eval("x")}") '// Get the DataType for 'Int' from the *second* instance. Dim intType_from_uc2 = uc2.DataTypeOf("Int") '// This should be uc2, so evaluating 'x' should yield 200. parent = intType_from_uc2.uCalc Console.WriteLine($"Parent of intType_from_uc2 evaluates 'x' to: {parent.Eval("x")}") End Sub End Module