Book Image

haXe 2 Beginner's Guide

5 (1)
Book Image

haXe 2 Beginner's Guide

5 (1)

Overview of this book

Table of Contents (21 chapters)
haxe 2
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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