DarkWiiPlayer / moonxml-old

A simple DSL made in moonscript to generate simple XML-based data
The Unlicense
2 stars 1 forks source link

A large number of automated tests fail #4

Closed Lukc closed 5 years ago

Lukc commented 5 years ago

I’m using the rockspec provided by the repository and Lua 5.1, on Arch Linux.

Here’s the full output for further reference:

<a_thing>
</a_thing>
+<t>
</t>
-<t>
test
</t>
-<outer>
<inner>
</inner>
</outer>
-<elem attrib="value">
</elem>
-<body>
</body>
+<br>
-<br>
test
</br>
-<span>
</span>
-<text>
string
</text>
-
2 successes / 8 failures / 0 errors / 0 pending : 0.016595 seconds

Failure -> xml_spec.moon @ 20
moonxml xml tags should not have closing tags when empty
(tail call):-1: Expected objects to be equal.
Passed in:
(string) ''
Expected:
(string) '<t />'

Failure -> (tail call) @ -1
moonxml xml tags should have closing tags when not empty
(tail call):-1: Expected objects to be equal.
Passed in:
(string) ''
Expected:
(string) '<t>test</t>'

Failure -> (tail call) @ -1
moonxml xml nested tags should work
(tail call):-1: Expected objects to be equal.
Passed in:
(string) ''
Expected:
(string) '<outer><inner /></outer>'

Failure -> (tail call) @ -1
moonxml xml attributes should work
(tail call):-1: Expected objects to be equal.
Passed in:
(string) ''
Expected:
(string) '<elem attrib="value" />'

Failure -> xml_spec.moon @ 38
moonxml html void tags should not have closing tags when empty
(tail call):-1: Expected objects to be equal.
Passed in:
(string) ''
Expected:
(string) '<br>'

Failure -> (tail call) @ -1
moonxml html void tags should have closing tags when not empty
(tail call):-1: Expected objects to be equal.
Passed in:
(string) ''
Expected:
(string) '<br>test</br>'

Failure -> (tail call) @ -1
moonxml html non-void tags should always have closing tags
xml_spec.moon:45: Expected objects to be equal.
Passed in:
(string) ''
Expected:
(string) '<span></span>'

Failure -> (tail call) @ -1
additional arguments should get passed
xml_spec.moon:49: Expected objects to be equal.
Passed in:
(string) ''
Expected:
(string) '<text>string</text>'
DarkWiiPlayer commented 5 years ago

After some quick testing, it's become obvious that in the test cases the print function is not overridden, so instead of writing the result into the buffer it is just writing it to stdout. I have no idea right now why that could be, and trying it out in a separate file it actually works as it should. I will try to find the root of this problem within the coming days though.

DarkWiiPlayer commented 5 years ago

After some hours of staring at the screen in bewilderment at why hates me so much, I've pinned the problem down to setfenv() simply not doing what I want it to in line 59. It basically does nothing. The environment of the function does not change and the standard print function is used instead.

DarkWiiPlayer commented 5 years ago

After 3 more minutes of thinking I realized that I am simply stupid. For whatever reason I was completely convinced that in lua 5.1 I could set the current environment by assigning _G just like how I assign _ENV in 5.2+. Took me looking at the line for 2 seconds and I noticed how that makes no damn sense at all and that I need to use setfenv(1, <env>) instead. It's fixed now (expect commit soon).

DarkWiiPlayer commented 5 years ago

Okay, it should be fixed now