#!/usr/bin/python """Eep RDF API: Built-Ins Test Suite""" __author__ = 'Sean B. Palmer' __license__ = 'Copyright (C) 2002 Sean B. Palmer. GNU GPL 2' import cwmclone, n3 from eep3 import api, query, ntuples def test(): testFiles = [ """{ ?x ?y ?z . ?x ?z } => { ?x <#notEqualTo> ?z } . <#p> <#q> <#p> .""", """{ ?x ?y ?z . ?x ?p } => { ?x <#uri> ?p } . <#p> <#q> <#r> . <#x> <#y> <#z> .""", """{ ?x ?y ?z . ?x ?z } => { ?x <#notEqualTo> ?z } . "p" <#q> "r" . <#p> <#q> <#p> . "p" <#q> "p" . "x" _:y "z" .""", # """{ ?x <#type> <#Target> . # ?x ?z } => # { ?x <#sha512> ?z } . # "blargh" <#type> <#Target> .""", # """{ ?x <#type> <#Target> . # ?x ?z . } => # { ?x <#resolvesTo> ?z . } . # <#type> <#Target> .""", """{ ?x <#y> ?z . ?x ?z } => { ?x <#startsWith> ?z } . "blargh" <#y> "bla" . "blargh" <#y> "xyz" .""", """{ ?x <#y> ?z . ?x ?p . ?p ?z } => { ?x <#uriStartsWith> ?z } . <#y> "bla" . <#y> "xyz" .""", """{ ?x a <#Target>; ?y } => { ?y a <#Result> } . ("x" "y" "z") a <#Target> .""", """{ <#p> <#q> ?r . ("p" "q" ?r) ?y } => { ?y a <#Result> } . <#p> <#q> "r" .""", """ dc:title "blargh"; rdfs:seeAlso . { ("" ?title "") string:concat ?output . ?x dc:title ?title; rdfs:seeAlso ?also . ?also log:uri ?uri } => { ?x <#htmlStuff> ?output; <#rdfsU> ?uri } .""" ] import n3s for testFile in testFiles: print testFile testFile = n3s.process(testFile) store = n3.parse(testFile, '') print n3.serialize(cwmclone.filter(store)) if __name__=="__main__": test()