]> gitweb.factorcode.org Git - factor.git/commitdiff
Throw an error if Chloe encounters an unknown tag
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Mon, 12 Jan 2009 22:17:52 +0000 (16:17 -0600)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Mon, 12 Jan 2009 22:17:52 +0000 (16:17 -0600)
basis/html/templates/chloe/chloe-tests.factor
basis/html/templates/chloe/compiler/compiler.factor
basis/html/templates/chloe/test/test13.xml [new file with mode: 0644]

index 5114b4088adf95d0286a4df4a679901e5a181713..542dfa0e05344d6a1f4126dbfee75a178f0351ec 100644 (file)
@@ -1,7 +1,8 @@
 USING: html.templates html.templates.chloe
 tools.test io.streams.string kernel sequences ascii boxes
 namespaces xml html.components html.forms
-splitting unicode.categories furnace accessors ;
+splitting unicode.categories furnace accessors
+html.templates.chloe.compiler ;
 IN: html.templates.chloe.tests
 
 : run-template
@@ -163,3 +164,9 @@ TUPLE: person first-name last-name ;
         "test12" test-template call-template
     ] run-template
 ] unit-test
+
+[
+    [
+        "test13" test-template call-template
+    ] run-template
+] [ error>> T{ unknown-chloe-tag f "this-tag-does-not-exist" } = ] must-fail-with
index d4f34ab8aa969ef9ad8bb8ac0b395389b6113dad..331b565b98e8c47f3be4a6b83dd1f3ccb6e62f80 100644 (file)
@@ -76,10 +76,13 @@ DEFER: compile-element
         [ drop tag-stack get pop* ]
     } cleave ;
 
+ERROR: unknown-chloe-tag tag ;
+
 : compile-chloe-tag ( tag -- )
-    ! "Unknown chloe tag: " prepend throw
     dup main>> dup tags get at
-    [ curry assert-depth ] [ 2drop ] ?if ;
+    [ curry assert-depth ]
+    [ unknown-chloe-tag ]
+    ?if ;
 
 : compile-element ( element -- )
     {
diff --git a/basis/html/templates/chloe/test/test13.xml b/basis/html/templates/chloe/test/test13.xml
new file mode 100644 (file)
index 0000000..adf5daf
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version='1.0' ?>
+
+<t:chloe xmlns:t="http://factorcode.org/chloe/1.0">
+
+  <t:this-tag-does-not-exist />
+
+</t:chloe>