Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit c072f74

Browse files
committed
tests
1 parent 65f8db2 commit c072f74

5 files changed

Lines changed: 327 additions & 0 deletions

File tree

test/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# feathersui-xml tests
2+
3+
Automated tests created with [utest](https://lib.haxe.org/p/utest).
4+
5+
## Run Neko tests
6+
7+
To run tests with Neko, run the following command:
8+
9+
```sh
10+
openfl test neko
11+
```
12+
13+
## Run HashLink tests
14+
15+
To run tests with HashLink, run the following command:
16+
17+
```sh
18+
openfl test hl
19+
```
20+
21+
## Run Adobe AIR tests
22+
23+
To run tests with Adobe AIR, use the following command:
24+
25+
```sh
26+
openfl test air
27+
```
28+
29+
## Run Windows tests
30+
31+
To run CPP tests on Windows, use the following command:
32+
33+
```sh
34+
openfl test windows
35+
```
36+
37+
## Run macOS tests
38+
39+
To run CPP tests on macOS, use the following command:
40+
41+
```sh
42+
openfl test mac
43+
```
44+
45+
## Run Linux tests
46+
47+
To run CPP tests on Linux, use the following command:
48+
49+
```sh
50+
openfl test linux
51+
```
52+
53+
## Run HTML/JS tests
54+
55+
To run tests with HTML/JS, run the following command:
56+
57+
```sh
58+
openfl test html5
59+
```

test/project.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<project>
3+
4+
<meta title="XML Tests" package="com.feathersui.xml.tests" version="1.0.0" company="Bowler Hat LLC" />
5+
<app main="TestMain" file="FeathersXMLTests" />
6+
7+
<source path="src" />
8+
<source path="../src" />
9+
10+
<haxelib name="openfl" />
11+
<haxelib name="feathersui" />
12+
<haxelib name="utest" />
13+
14+
<template path="templates" if="html5"/>
15+
</project>

test/src/TestMain.hx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import openfl.display.Sprite;
2+
import utest.Runner;
3+
import utest.ui.Report;
4+
5+
class TestMain extends Sprite {
6+
public function new() {
7+
super();
8+
9+
var runner = new Runner();
10+
runner.addCase(new com.feathersui.xml.TestXmlComponentDeclarationsCoreTypes());
11+
12+
// a report prints the final results after all tests have run
13+
Report.create(runner);
14+
15+
// don't forget to start the runner
16+
runner.run();
17+
}
18+
}
Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
package com.feathersui.xml;
2+
3+
import utest.Assert;
4+
import utest.Test;
5+
6+
class TestXmlComponentDeclarationsCoreTypes extends Test {
7+
public function new() {
8+
super();
9+
}
10+
11+
public function testFloat():Void {
12+
var instance = XmlComponent.withMarkup(
13+
// @formatter:off
14+
'<hx:Dynamic xmlns:hx="http://ns.haxe.org/4/xml">
15+
<hx:Declarations>
16+
<hx:Float id="float">123.4</hx:Float>
17+
</hx:Declarations>
18+
</hx:Dynamic>');
19+
// @formatter:on
20+
Assert.equals(123.4, instance.float);
21+
}
22+
23+
public function testInt():Void {
24+
var instance = XmlComponent.withMarkup(
25+
// @formatter:off
26+
'<hx:Dynamic xmlns:hx="http://ns.haxe.org/4/xml">
27+
<hx:Declarations>
28+
<hx:Int id="int">-123</hx:Int>
29+
</hx:Declarations>
30+
</hx:Dynamic>');
31+
// @formatter:on
32+
Assert.equals(-123, instance.int);
33+
}
34+
35+
public function testUInt():Void {
36+
var instance = XmlComponent.withMarkup(
37+
// @formatter:off
38+
'<hx:Dynamic xmlns:hx="http://ns.haxe.org/4/xml">
39+
<hx:Declarations>
40+
<hx:UInt id="uint">123</hx:UInt>
41+
</hx:Declarations>
42+
</hx:Dynamic>');
43+
// @formatter:on
44+
Assert.equals(123, instance.uint);
45+
}
46+
47+
public function testBoolFalse():Void {
48+
var instance = XmlComponent.withMarkup(
49+
// @formatter:off
50+
'<hx:Dynamic xmlns:hx="http://ns.haxe.org/4/xml">
51+
<hx:Declarations>
52+
<hx:Bool id="bool">false</hx:Bool>
53+
</hx:Declarations>
54+
</hx:Dynamic>');
55+
// @formatter:on
56+
Assert.isFalse(instance.bool);
57+
}
58+
59+
public function testBoolTrue():Void {
60+
var instance = XmlComponent.withMarkup(
61+
// @formatter:off
62+
'<hx:Dynamic xmlns:hx="http://ns.haxe.org/4/xml">
63+
<hx:Declarations>
64+
<hx:Bool id="bool">true</hx:Bool>
65+
</hx:Declarations>
66+
</hx:Dynamic>');
67+
// @formatter:on
68+
Assert.isTrue(instance.bool);
69+
}
70+
71+
public function testString():Void {
72+
var instance = XmlComponent.withMarkup(
73+
// @formatter:off
74+
'<hx:Dynamic xmlns:hx="http://ns.haxe.org/4/xml">
75+
<hx:Declarations>
76+
<hx:String id="string">Hello XML</hx:String>
77+
</hx:Declarations>
78+
</hx:Dynamic>');
79+
// @formatter:on
80+
Assert.equals("Hello XML", instance.string);
81+
}
82+
83+
public function testArrayEmpty():Void {
84+
var instance = XmlComponent.withMarkup(
85+
// @formatter:off
86+
'<hx:Dynamic xmlns:hx="http://ns.haxe.org/4/xml">
87+
<hx:Declarations>
88+
<hx:Array id="array"></hx:Array>
89+
</hx:Declarations>
90+
</hx:Dynamic>');
91+
// @formatter:on
92+
Assert.equals(0, instance.array.length);
93+
}
94+
95+
public function testArrayWithItems():Void {
96+
var instance = XmlComponent.withMarkup(
97+
// @formatter:off
98+
'<hx:Dynamic xmlns:hx="http://ns.haxe.org/4/xml">
99+
<hx:Declarations>
100+
<hx:Array id="array">
101+
<hx:String>a</hx:String>
102+
<hx:String>b</hx:String>
103+
<hx:String>c</hx:String>
104+
</hx:Array>
105+
</hx:Declarations>
106+
</hx:Dynamic>');
107+
// @formatter:on
108+
Assert.equals(3, instance.array.length);
109+
Assert.equals("a", instance.array[0]);
110+
Assert.equals("b", instance.array[1]);
111+
Assert.equals("c", instance.array[2]);
112+
}
113+
114+
public function testDynamicNoFields():Void {
115+
var instance = XmlComponent.withMarkup(
116+
// @formatter:off
117+
'<hx:Dynamic xmlns:hx="http://ns.haxe.org/4/xml">
118+
<hx:Declarations>
119+
<hx:Dynamic id="dyn"></hx:Dynamic>
120+
</hx:Declarations>
121+
</hx:Dynamic>');
122+
// @formatter:on
123+
Assert.equals(0, Reflect.fields(instance.dyn).length);
124+
}
125+
126+
public function testDynamicAttributeProperty():Void {
127+
var instance = XmlComponent.withMarkup(
128+
// @formatter:off
129+
'<hx:Dynamic xmlns:hx="http://ns.haxe.org/4/xml">
130+
<hx:Declarations>
131+
<hx:Dynamic id="dyn" value="123.4"></hx:Dynamic>
132+
</hx:Declarations>
133+
</hx:Dynamic>');
134+
// @formatter:on
135+
Assert.equals(123.4, instance.dyn.value);
136+
}
137+
138+
public function testDynamicElementProperty():Void {
139+
var instance = XmlComponent.withMarkup(
140+
// @formatter:off
141+
'<hx:Dynamic xmlns:hx="http://ns.haxe.org/4/xml">
142+
<hx:Declarations>
143+
<hx:Dynamic id="dyn">
144+
<hx:value>123.4</hx:value>
145+
</hx:Dynamic>
146+
</hx:Declarations>
147+
</hx:Dynamic>');
148+
// @formatter:on
149+
Assert.equals(123.4, instance.dyn.value);
150+
}
151+
152+
public function testDynamicAttributeAndElementProperties():Void {
153+
var instance = XmlComponent.withMarkup(
154+
// @formatter:off
155+
'<hx:Dynamic xmlns:hx="http://ns.haxe.org/4/xml">
156+
<hx:Declarations>
157+
<hx:Dynamic id="dyn" value1="123.4">
158+
<hx:value2>456.7</hx:value2>
159+
</hx:Dynamic>
160+
</hx:Declarations>
161+
</hx:Dynamic>');
162+
// @formatter:on
163+
Assert.equals(123.4, Reflect.field(instance.dyn, "value1"));
164+
Assert.equals(456.7, Reflect.field(instance.dyn, "value2"));
165+
}
166+
167+
public function testAnyNoFields():Void {
168+
var instance = XmlComponent.withMarkup(
169+
// @formatter:off
170+
'<hx:Dynamic xmlns:hx="http://ns.haxe.org/4/xml">
171+
<hx:Declarations>
172+
<hx:Any id="any"></hx:Any>
173+
</hx:Declarations>
174+
</hx:Dynamic>');
175+
// @formatter:on
176+
Assert.equals(0, Reflect.fields(instance.any).length);
177+
}
178+
179+
public function testAnyAttributeProperty():Void {
180+
var instance = XmlComponent.withMarkup(
181+
// @formatter:off
182+
'<hx:Dynamic xmlns:hx="http://ns.haxe.org/4/xml">
183+
<hx:Declarations>
184+
<hx:Any id="any" value="123.4"></hx:Any>
185+
</hx:Declarations>
186+
</hx:Dynamic>');
187+
// @formatter:on
188+
Assert.equals(123.4, Reflect.field(instance.any, "value"));
189+
}
190+
191+
public function testAnyElementProperty():Void {
192+
var instance = XmlComponent.withMarkup(
193+
// @formatter:off
194+
'<hx:Dynamic xmlns:hx="http://ns.haxe.org/4/xml">
195+
<hx:Declarations>
196+
<hx:Any id="any">
197+
<hx:value>123.4</hx:value>
198+
</hx:Any>
199+
</hx:Declarations>
200+
</hx:Dynamic>');
201+
// @formatter:on
202+
Assert.equals(123.4, Reflect.field(instance.any, "value"));
203+
}
204+
205+
public function testAnyAttributeAndElementProperties():Void {
206+
var instance = XmlComponent.withMarkup(
207+
// @formatter:off
208+
'<hx:Dynamic xmlns:hx="http://ns.haxe.org/4/xml">
209+
<hx:Declarations>
210+
<hx:Any id="any" value1="123.4">
211+
<hx:value2>456.7</hx:value2>
212+
</hx:Any>
213+
</hx:Declarations>
214+
</hx:Dynamic>');
215+
// @formatter:on
216+
Assert.equals(123.4, Reflect.field(instance.any, "value1"));
217+
Assert.equals(456.7, Reflect.field(instance.any, "value2"));
218+
}
219+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>::APP_TITLE::</title>
6+
<script type="text/javascript" src="./::APP_FILE::.js"></script>
7+
</head>
8+
<body>
9+
<noscript
10+
>Please enable JavaScript in your web browser to run tests.</noscript
11+
>
12+
<script type="text/javascript">
13+
lime.$scripts["::APP_FILE::"]();
14+
</script>
15+
</body>
16+
</html>

0 commit comments

Comments
 (0)