[PATCH 2/4] vbscript: Add for each tests on array

Piotr Caban <[email protected]> Wed, 8 Nov 2017 15:05:06 +0100
Newsgroups gmane.comp.emulators.wine.patches
Message-ID <[email protected]>
Signed-off-by: Piotr Caban <[email protected]>
---
  dlls/vbscript/tests/lang.vbs | 29 +++++++++++++++++++++++++++++
  1 file changed, 29 insertions(+)
0002-vbscript-Add-for-each-tests-on-array.txt (text/x-patch, 1 KB)
diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs
index a904f5dafa..2af77bdfcc 100644
--- a/dlls/vbscript/tests/lang.vbs
+++ b/dlls/vbscript/tests/lang.vbs
@@ -1304,6 +1304,35 @@ arr(0) = "not modified"
 modifyarr(arr)
 Call todo_wine_ok(arr(0) = "not modified", "arr(0) = " & arr(0))
 
+for x = 0 to UBound(arr)
+    arr(x) = x
+next
+y = 0
+for each x in arr
+    Call ok(x = y, "x = " & x & ", expected " & y)
+    Call ok(arr(y) = y, "arr(" & y & ") = " & arr(y))
+    arr(y) = 1
+    x = 1
+    y = y+1
+next
+Call ok(y = 4, "y = " & y & " after array enumeration")
+
+for x=0 to UBound(arr2, 1)
+    for y=0 to UBound(arr2, 2)
+        arr2(x, y) = x + y*(UBound(arr2, 1)+1)
+    next
+next
+y = 0
+for each x in arr2
+    Call ok(x = y, "x = " & x & ", expected " & y)
+    y = y+1
+next
+Call ok(y = 20, "y = " & y & " after array enumeration")
+
+for each x in noarr
+    Call ok(false, "Empty array contains: " & x)
+next
+
 ' It's allowed to declare non-builtin RegExp class...
 class RegExp
      public property get Global()