O'Reilly logo

haXe 2 by Benjamin Dasnois

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action—Testing our parser

Before continuing any further, we should test our parser in order to be sure that it works as expected.

To do this, we can use the following configuration file:

nameMyComponent 1
textHelloWorld 0

If everything works as expected, we should have a name metadata with the value MyComponent and a property named text with the value HelloWorld.

Let's write a simple test class:

class ComponentImpl
{
public static function main(): Void
{
var comp = ComponentParser.parseConfigurationFile("conf.txt");
trace(comp.properties.get("text"));
trace(comp.metadata.get("name"));
}
}

Now, if everything went well, while running this program, you should get the following output:

ComponentImpl.hx:6: HelloWorld ComponentImpl.hx:7: MyComponent ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required