AST testing
This commit is contained in:
@@ -28,8 +28,6 @@ type
|
||||
procedure TestScalarArray;
|
||||
[Test]
|
||||
procedure TestScalarTuple;
|
||||
[Test]
|
||||
procedure TestScalarRecordAndDefinition;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@@ -80,39 +78,6 @@ begin
|
||||
Assert.AreEqual(Int64(0), Length(arr.Items), 'Empty array length should be zero');
|
||||
end;
|
||||
|
||||
procedure TTestPOD.TestScalarRecordAndDefinition;
|
||||
var
|
||||
recDef: TScalarRecordDefinition;
|
||||
values: TArray<TScalar.TValue>;
|
||||
rec: TScalarRecord;
|
||||
mismatchedValues: TArray<TScalar.TValue>;
|
||||
begin
|
||||
// 1. Create a definition
|
||||
recDef :=
|
||||
TScalarRecordDefinition
|
||||
.Create([TScalarRecordField.Create('ID', TScalar.TKind.Ordinal), TScalarRecordField.Create('Price', TScalar.TKind.Float)]);
|
||||
Assert.AreEqual(Int64(2), Length(recDef.Fields), 'Record definition field count mismatch');
|
||||
Assert.AreEqual('Price', recDef.Fields[1].Name, 'Record definition field name mismatch');
|
||||
|
||||
// 2. Create a matching set of values
|
||||
values := [TScalar.FromInt64(99).Value, TScalar.FromDouble(19.95).Value];
|
||||
|
||||
// 3. Create the record
|
||||
rec := TScalarRecord.Create(recDef, values);
|
||||
Assert.AreEqual(Int64(2), Length(rec.Fields), 'Record field count mismatch');
|
||||
Assert.AreEqual(19.95, rec.Fields[1].AsDouble, 1E-12, 'Record field value mismatch');
|
||||
Assert.AreEqual(Int64(99), rec.Items['ID'].Value.AsInt64, 'Record item by name mismatch');
|
||||
Assert.AreEqual(TScalar.TKind.Float, rec.Items['Price'].Kind, 'Record item kind by name mismatch');
|
||||
|
||||
// 4. Test assertion for mismatched field count
|
||||
mismatchedValues := [TScalar.FromInt64(1).Value];
|
||||
Assert.WillRaise(
|
||||
procedure begin rec := TScalarRecord.Create(recDef, mismatchedValues); end,
|
||||
EAssertionFailed,
|
||||
'Mismatched field/value count should raise an assertion'
|
||||
);
|
||||
end;
|
||||
|
||||
procedure TTestPOD.TestScalarTuple;
|
||||
var
|
||||
tuple: TScalarTuple;
|
||||
|
||||
Reference in New Issue
Block a user