Mei Liu has uploaded a new change for review.

Change subject: [WIP]Add list in policy
......................................................................

[WIP]Add list in policy

Change-Id: If46896db09fa1e0a36a77a6b50e103b2f15a4926
Signed-off-by: MeiLiu <[email protected]>
---
M mom/Policy/Parser.py
M tests/ParserTests.py
2 files changed, 22 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/mom refs/changes/02/17102/1

diff --git a/mom/Policy/Parser.py b/mom/Policy/Parser.py
index f3be3dc..6d5599f 100644
--- a/mom/Policy/Parser.py
+++ b/mom/Policy/Parser.py
@@ -387,6 +387,14 @@
             self.stack.leave_scope()
         return result
 
+    def c_list(self, *items):
+        return list(items)
+
+    def c_append(self, iterable, item):
+        if isinstance(iterable, list):
+            iterable.append(item)
+            return iterable
+
     def c_if(self, cond, yes, no):
         'value code code'
 
diff --git a/tests/ParserTests.py b/tests/ParserTests.py
index 8a04636..895aedf 100644
--- a/tests/ParserTests.py
+++ b/tests/ParserTests.py
@@ -160,6 +160,20 @@
         """
         self.verify(pol, [ 1, 0, 'f', 4, 0, "yes"])
 
+    def test_list(self):
+        pol = """
+        (defvar a (list 1 "a" 8))
+        """
+        self.verify(pol, [[1, "a", 8]])
+
+    def test_append(self):
+        pol = """
+        (defvar a (list (+ 1 5) 3))
+        (append a "a")
+        (append (list 7 8) "b")
+        """
+        self.verify(pol, [[6, 3, "a"], [6, 3, "a"], [7, 8, "b"]])
+
     def test_scope(self):
         pol = """
         (defvar a 10)


-- 
To view, visit http://gerrit.ovirt.org/17102
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If46896db09fa1e0a36a77a6b50e103b2f15a4926
Gerrit-PatchSet: 1
Gerrit-Project: mom
Gerrit-Branch: master
Gerrit-Owner: Mei Liu <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to