1. james woodyatt
  2. oni

Commits

jhwoodyatt  committed dd9cc6a

Submit of cf-0.3 release.

  • Participants
  • Parent commits d8dac4b
  • Branches default

Comments (0)

Files changed (1)

File cf/t/t_cf.ml

View file
  • Ignore whitespace
             if token <> token0 then
                 failwith (sprintf "Bad match! [msg='%s']" token)
     end
+    
+    module L2 = struct
+        let p =
+            let q0 = Cf_scan_parser.scanf "%3u" (fun y -> y) in
+            let q1 = Cf_scan_parser.scanf "%c" (fun y -> y) in
+            let q2 = Cf_scan_parser.scanf "%3u" (fun y -> y) in
+            q0 >>= fun v0 ->
+            q1 >>= fun v1 ->
+            q2 >>= fun v2 ->
+            ~:(v0, v1, v2)
+        
+        let c = new Cf_lexer.cursor 0
+        
+        let y s = p (Cf_parser.X.weave ~c (Cf_seq.of_string s))
+        
+        let test () =
+            match y "1234567" with
+            | Some ((123, '4', 567), z) when Lazy.force z = Cf_seq.Z ->
+                ()
+            | Some ((123, '4', 567), z) ->
+                failwith (Cf_seq.to_string (Cf_seq.first z))
+            | Some ((v0, v1, v2), _) ->
+                failwith (Printf.sprintf "%02u, '%c', %02u" v0 v1 v2)
+            | _ ->
+                failwith "No match!"
+    end
 
     let test () =
         let lexer =
             end
         in
         L1.test1 lexer;
-        L1.test2 lexer
+        L1.test2 lexer;
+        L2.test ()
 end
 
 module T7 = struct
             end;
             ignore (message_of_uri_reference result)
         
+        let unresolved_list = [
+            "http://a", "../b";
+        ]
+        
+        let unresolved (basestr, relstr) =
+            let base = message_to_uri (Cf_message.create basestr) in
+            let rel = message_to_uri (Cf_message.create relstr) in
+            let base =
+                match base with
+                | A base -> base
+                | _ -> invalid_arg "base not absolute"
+            in
+            let rel =
+                match rel with
+                | R rel -> rel
+                | _ -> invalid_arg "rel not relative"
+            in
+            try
+                ignore (refer_to_base ~base ~rel);
+                failwith "expected to catch Rel_undefined."
+            with
+            | Rel_undefined ->
+                ()            
+        
         let test () =
             if basestr <> "http://a/b/c/d;p?q" then
                 failwith "base URI emit error";
-            List.iter resolve resolve_list
+            List.iter resolve resolve_list;
+            List.iter unresolved unresolved_list
     end
 
     let test () =