问题描述
我计划在Haxe的子集中编写Haxe库,该子集将编译为每种Haxe目标语言.是否有任何方法可以验证Haxe程序是否可以编译为所有目标语言,并且可以在没有手动测试每个目标平台上的编译代码的情况下做到这一点?
I plan to write Haxe libraries in a subset of Haxe that will compile to every Haxe target language. Is there any way to verify that a Haxe program will compile to all target languages, and is it possible to do this without manually testing the compiled code on each target platform?
例如,是否有一种方法可以确保以下代码在每个目标平台上均有效,而无需在每个平台上手动进行测试?
For example, is there a way to ensure that the following code is valid on every target platform, without testing it manually on every single platform?
class Test {
static function main(){
trace("How can I check to see which platforms this program will run on?");
}
}
编辑:我编写了一个compile.hxml
文件,该文件将类Test.hx
编译为各种目标语言.必须首先安装所有必需的haxelib库,以使其正常运行.
I have written a compile.hxml
file that compiles the class Test.hx
to various target languages. All the necessary haxelib libraries will need to be installed first in order for it to work properly.
-js test.js
-main Test
--next
-php www
-main Test
--next
-cpp cpp
-debug
-main Test
--next
-main Test
-java java
--next
-cs test
-main Test
-D haxe3
推荐答案
我已经用我的一些库做了一些类似的事情( mdown 和 detox ),并且我能够使用以下方法测试多个平台MUnit/MassiveUnit:
I have done some similar things with a few of my libraries (mdown and detox), and I was able to test several of the platforms using MUnit / MassiveUnit:
https://github.com/massiveinteractive/MassiveUnit
这是一个单元测试平台,可用于检查跨多个目标的行为.还有 utest ,还有其他
This is a unit testing platform that you can use to check your behaviour across multiple targets. There is also utest, and possibly others.
当前,munit可以在以下目标上自动为您的代码运行测试:
Currently munit can automatically run tests for your code on the following targets:
- Neko
- Flash 8
- Flash 9 +
- JavaScript
- CPP
有添加其他目标支持的说明此处
There are instructions for adding support for other targets here
(如果您对单元测试了解不多,这是一种编写大量小型测试的方法,可确保您的库/代码表现出预期的效果,并且非常适合检查跨平台的功能以及确保您在更改代码时不会破坏任何东西.)
(If you don't know much about unit testing - it's a way to write lots of small tests to make sure your library/code behaves as expected, and is perfect for checking that things function across platforms, as well as making sure you don't break things when you change your code.)
这篇关于确保Haxe程序将在所有平台上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!