|
From: <cw...@us...> - 2007-08-13 18:05:11
|
Revision: 521
http://rdfapi-php.svn.sourceforge.net/rdfapi-php/?rev=521&view=rev
Author: cweiske
Date: 2007-08-13 11:05:10 -0700 (Mon, 13 Aug 2007)
Log Message:
-----------
Squash final nesting bug
Modified Paths:
--------------
trunk/rdfapi-php/api/syntax/N3Serializer.php
trunk/rdfapi-php/test/unit/Syntax/n3Serializer_test.php
Modified: trunk/rdfapi-php/api/syntax/N3Serializer.php
===================================================================
--- trunk/rdfapi-php/api/syntax/N3Serializer.php 2007-08-13 17:51:59 UTC (rev 520)
+++ trunk/rdfapi-php/api/syntax/N3Serializer.php 2007-08-13 18:05:10 UTC (rev 521)
@@ -181,20 +181,29 @@
arsort($count);
- foreach ( $count as $k=>$v) {
+ foreach ( $count as $k => $v) {
$this->doResource($resources[$k]);
// $this->res.=" .\n";
}
- $c = 0;
- foreach ($this->resourcetext as $r => $t) {
- if (preg_match_all('/'.MAGIC_STRING.'([^ ]+)'.MAGIC_STRING.'/', $t, $ms, PREG_SET_ORDER)) {
- foreach ($ms as $mseach) {
- $rp = $this->resourcetext[$mseach[1]];
- $t = preg_replace('/'.MAGIC_STRING.$mseach[1].MAGIC_STRING.'/', $rp, $t);
+ //make all replacements
+ do {
+ $bReplacements = false;
+ foreach ($this->resourcetext as $r => $t) {
+ if (preg_match_all('/'.MAGIC_STRING.'([^ ]+)'.MAGIC_STRING.'/', $t, $ms, PREG_SET_ORDER)) {
+ foreach ($ms as $mseach) {
+ $rp = $this->resourcetext[$mseach[1]];
+ $this->resourcetext[$r] = preg_replace('/'.MAGIC_STRING.$mseach[1].MAGIC_STRING.'/', $rp, $t);
+ $bReplacements = true;
+ }
}
+
}
+ } while ($bReplacements);
+ //after all replacements took place, put the lines out
+ $c = 0;
+ foreach ($this->resourcetext as $r => $t) {
if ($this->debug) {
$this->res .= $c . ': ';
}
Modified: trunk/rdfapi-php/test/unit/Syntax/n3Serializer_test.php
===================================================================
--- trunk/rdfapi-php/test/unit/Syntax/n3Serializer_test.php 2007-08-13 17:51:59 UTC (rev 520)
+++ trunk/rdfapi-php/test/unit/Syntax/n3Serializer_test.php 2007-08-13 18:05:10 UTC (rev 521)
@@ -338,8 +338,8 @@
- function testNest()
- {return;
+ function testNestDeeply()
+ {
$mod = new MemModel();
$b100 = new BlankNode($mod);
$b110 = new BlankNode($mod);
@@ -374,11 +374,9 @@
//test if it can be loaded
$par = new N3Parser();
$mod2 = $par->parse2model($str, false);
- var_dump($str);//, $mod2->triples);
+ //var_dump($str, $mod2->triples);
- $this->assertEqual($mod->size(), $mod2->size(), 'Original model size and loaded model size should equal');
- $this->assertTrue($mod->containsAll($mod2), 'Original model should contain all triples of loaded model');
- $this->assertTrue($mod2->containsAll($mod), 'Loaded model should contain all triples of original model');
+ $this->compareModelsIgnoringBlankNodes($mod, $mod2);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|