Skip to content

Commit

Permalink
Add in a test file for some new xml features, from some ad hoc tests …
Browse files Browse the repository at this point in the history
…I was using.
  • Loading branch information
Whiteknight committed Jun 27, 2012
1 parent ae7a3f1 commit d770c23
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/unstable/xml/Text.winxed
Expand Up @@ -6,7 +6,7 @@ class Rosella.Xml.Text
var text;

// Constructor
function Text(string text) { self.text = text; }
function Text(string text) { self.text = Rosella.String.trim(text); }

// Get the raw text string
function get_text() { return self.text; }
Expand Down
34 changes: 34 additions & 0 deletions t/xml/Tag.t
@@ -0,0 +1,34 @@
class Test_Xml_Tag
{
function get_children_named()
{
string x = <<:
<html>
<div>
<p type='Foo'>Test A</p>
<p>Text B</p>
</div>
<div>
<p>Test C</p>
<p type='Foo'>Test D</p>
</div>
</html>
:>>
;
var d = Rosella.Xml.read_string(x);
var c = d
.get_document_root()
.get_children_named("div")
.get_children_named("p", "Foo":[named('type')]);
self.assert.equal(elements(c.tags), 2);
self.assert.equal(Rosella.String.trim(c.tags[0].get_inner_xml()), "Test A");
self.assert.equal(Rosella.String.trim(c.tags[1].get_inner_xml()), "Test D");
}
}
function main[main]()
{
var core = load_packfile("rosella/core.pbc");
var(Rosella.initialize_rosella)("test", "xml", "string");
Rosella.Test.test(class Test_Xml_Tag);
}

0 comments on commit d770c23

Please sign in to comment.