您的位置:首页 > 其它

几种语言原生开发环境构建之--Elm语言

2016-08-07 13:23 429 查看

elm安装

$ npm install elm -g
$ elm
$ elm-repl  #repl命令行
$ elm-reactor #浏览器在线调试
$ elm-package #包管理
$ elm-make --help 编译

项目构建

初始化

$ mkdir src   && mkdir src/Test #源码目录,源代码文件都已大写开头
$ elm-package install  #初始化以及安装依赖


配置文件elm-package.json

{
"version": "1.0.0",
"summary": "helpful summary of your project, less than 80 characters",
"repository": "https://github.com/user/project.git",
"license": "MIT",
"source-directories": [
"src"
],
"exposed-modules": ["First"],
"native-modules": true,
"dependencies": {
"elm-lang/core": "4.0.4 <= v < 5.0.0",
"elm-lang/html": "1.1.0 <= v < 2.0.0"
},
"elm-version": "0.17.1 <= v < 0.18.0"
}

集成测试

配置依赖

#elm-package.json 安装依赖
"dependencies": {
"elm-lang/core": "4.0.4 <= v < 5.0.0",
"elm-lang/html": "1.1.0 <= v < 2.0.0"
,"evancz/elm-markdown":"3.0.0 <= v < 5.0.0"
,"elm-community/elm-test":"1.1.0 <= v < 5.0.0" #测试依赖
,"evancz/elm-graphics":"1.0.0 <= v < 5.0.0"
}


安装依赖

$ elm-package install


测试代码 src/Test/Example.elm

import List

import ElmTest exposing (..)

tests : List Test
tests =
[ 0 `equals` 1
, test "pass" <| assert True
, test "fail" <| assertNotEqual True False
]
++
(List.map defaultTest <| assertionList [1..10] [1..10])

consoleTests : Test
consoleTests =
suite "All Tests" tests

main =
runSuiteHtml consoleTests


开始测试

$ elm-reactor
$  firefox http://localhost:8000/src/Test/Example.elm

项目代码

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Elm