Browse Source

* Test for sequence result

Michaël Van Canneyt 1 year ago
parent
commit
05118c077f
1 changed files with 49 additions and 0 deletions
  1. 49 0
      packages/webidl/tests/tcwebidl2wasmjob.pas

+ 49 - 0
packages/webidl/tests/tcwebidl2wasmjob.pas

@@ -57,6 +57,7 @@ type
     procedure TestWJ_IntfFunction_Constructor;
     procedure TestWJ_IntfFunction_ArrayBufferArg;
     procedure TestWJ_IntfFunction_ArrayBufferViewArg;
+    procedure TestWJ_IntfFunction_SequenceResult;
     // Namespace attribute
     procedure TestWJ_NamespaceAttribute_Boolean;
     // maplike
@@ -1128,6 +1129,54 @@ begin
     ''  ]);
 end;
 
+procedure TTestWebIDL2WasmJob.TestWJ_IntfFunction_SequenceResult;
+begin
+  TestWebIDL([
+  'interface Attr {',
+  '  sequence<long> vibrate();',
+  '};',
+  ''],
+  [
+   'Type',
+   '',
+   '  // Forward class definitions',
+   '  IJSAttr = interface;',
+   '  TJSAttr = class;',
+   '',
+   '  { --------------------------------------------------------------------',
+   '    TJSAttr',
+   '    --------------------------------------------------------------------}',
+   '',
+   '  TIntegerDynArray = IJSArray; // array of Integer',
+   '',
+   '  IJSAttr = interface(IJSObject)',
+   '    [''{AA94F48A-2BFB-3877-82A6-208CA4B2AF2A}'']',
+   '    function vibrate: TIntegerDynArray;',
+   '  end;',
+   '',
+   '  TJSAttr = class(TJSObject,IJSAttr)',
+   '  Private',
+   '  Public',
+   '    function vibrate: TIntegerDynArray;',
+   '    class function Cast(const Intf: IJSObject): IJSAttr;',
+   '  end;',
+   '',
+   'implementation',
+   '',
+   'function TJSAttr.vibrate: TIntegerDynArray;',
+   'begin',
+   '  Result:=InvokeJSObjectResult(''vibrate'',[],TJSArray) as TIntegerDynArray;',
+   'end;',
+   '',
+   'class function TJSAttr.Cast(const Intf: IJSObject): IJSAttr;',
+   'begin',
+   '  Result:=TJSAttr.JOBCast(Intf);',
+   'end;',
+   '',
+   'end.'
+    ]);
+end;
+
 
 procedure TTestWebIDL2WasmJob.TestWJ_NamespaceAttribute_Boolean;
 begin