Ensure that a Haxe program will run on all platforms

时间秒杀一切 提交于 2019-12-06 11:23:29

问题


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?");
  }
}

EDIT: 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

回答1:


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

This is a unit testing platform that you can use to check your behaviour across multiple targets. There is also utest, and possibly others.

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.)



来源:https://stackoverflow.com/questions/14409869/ensure-that-a-haxe-program-will-run-on-all-platforms

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!