├── .github
└── workflows
│ └── ci.yml
├── .gitignore
├── CONTRIBUTING
├── INSTALL
├── LICENSE
├── NEWS
├── README
├── TODO
├── _file
├── .gitignore
├── LICENSE
├── README.md
├── elm.json
└── src
│ └── File
│ ├── Download.elm
│ └── Select.elm
├── another-elm
├── browser
├── .gitignore
├── LICENSE
├── README.md
├── elm.json
├── examples
│ ├── README.md
│ ├── elm.json
│ └── src
│ │ ├── Drag.elm
│ │ └── Url.elm
├── notes
│ ├── capture-vs-bubble.md
│ ├── chat.svg
│ ├── getElement.svg
│ ├── getViewport.svg
│ ├── getViewportOf.svg
│ ├── keyboard.md
│ ├── navigation-in-elements.md
│ └── properties-vs-attributes.md
├── notsrc
│ └── Debugger
│ │ ├── Expando.elm
│ │ ├── History.elm
│ │ ├── Main.elm
│ │ ├── Metadata.elm
│ │ ├── Overlay.elm
│ │ └── Report.elm
└── src
│ ├── Browser.elm
│ ├── Browser
│ ├── Dom.elm
│ ├── Events.elm
│ ├── Internal.elm
│ └── Navigation.elm
│ ├── Elm
│ └── Kernel
│ │ ├── Browser.js
│ │ ├── Debugger.notjs
│ │ └── Url.js
│ ├── Url.elm
│ └── Url
│ ├── Builder.elm
│ ├── Parser.elm
│ └── Parser
│ ├── Internal.elm
│ └── Query.elm
├── core
├── README.md
├── elm.json
└── src
│ ├── Array.elm
│ ├── Basics.elm
│ ├── Bitwise.elm
│ ├── Bytes.elm
│ ├── Bytes
│ ├── Decode.elm
│ └── Encode.elm
│ ├── Char.elm
│ ├── Debug.elm
│ ├── Dict.elm
│ ├── Elm
│ ├── JsArray.elm
│ └── Kernel
│ │ ├── Basics.js
│ │ ├── Bytes.js
│ │ ├── Channel.js
│ │ ├── Char.js
│ │ ├── Debug.js
│ │ ├── File.js
│ │ ├── Http.js
│ │ ├── JsArray.js
│ │ ├── List.js
│ │ ├── Parser.js
│ │ ├── Platform.js
│ │ ├── Scheduler.js
│ │ ├── String.js
│ │ ├── Time.js
│ │ └── Utils.js
│ ├── File.elm
│ ├── Http.elm
│ ├── HttpV1.elm
│ ├── HttpV1
│ └── Internal.elm
│ ├── List.elm
│ ├── Maybe.elm
│ ├── Parser.elm
│ ├── Parser
│ └── Advanced.elm
│ ├── Platform.elm
│ ├── Platform
│ ├── Cmd.elm
│ ├── Scheduler.elm
│ ├── Sub.elm
│ └── Unstable
│ │ ├── Channel.elm
│ │ ├── Effect.elm
│ │ ├── Effect2.elm
│ │ ├── Impure.elm
│ │ ├── Iterable.elm
│ │ ├── Scheduler.elm
│ │ ├── SubManager.elm
│ │ └── Task.elm
│ ├── Process.elm
│ ├── Random.elm
│ ├── Result.elm
│ ├── Set.elm
│ ├── String.elm
│ ├── Task.elm
│ ├── Time.elm
│ └── Tuple.elm
├── html
├── .gitignore
├── LICENSE
├── README.md
├── elm.json
└── src
│ ├── Elm
│ └── Kernel
│ │ └── VirtualDom.js
│ ├── Html.elm
│ ├── Html
│ ├── Attributes.elm
│ ├── Events.elm
│ ├── Keyed.elm
│ └── Lazy.elm
│ └── VirtualDom.elm
├── init.py
├── json
├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── elm.json
└── src
│ ├── Elm
│ └── Kernel
│ │ └── Json.js
│ └── Json
│ ├── Decode.elm
│ ├── Encode.elm
│ └── Internal.elm
├── make-pkg.sh
├── markdown
├── .gitignore
├── LICENSE
├── README.md
├── elm.json
└── src
│ ├── Elm
│ └── Kernel
│ │ └── Markdown.js
│ └── Markdown.elm
├── package.json
├── svg
├── .gitignore
├── LICENSE
├── README.md
├── elm.json
├── examples
│ └── Logo.elm
└── src
│ ├── Svg.elm
│ └── Svg
│ ├── Attributes.elm
│ ├── Events.elm
│ ├── Keyed.elm
│ └── Lazy.elm
├── test
├── .gitignore
├── .travis.yml
├── CHANGELOG.md
├── LICENSE
├── PUBLISHING.md
├── README.md
├── benchmarks
│ ├── Main.elm
│ ├── README.md
│ ├── Snippets.elm
│ └── elm-package.json
├── elm.json
├── package.json
├── src
│ ├── Elm
│ │ └── Kernel
│ │ │ ├── HtmlAsJson.js
│ │ │ └── Test.js
│ ├── Expect.elm
│ ├── Float.elm
│ ├── Fuzz.elm
│ ├── Fuzz
│ │ └── Internal.elm
│ ├── Lazy.elm
│ ├── Lazy
│ │ └── List.elm
│ ├── MicroRandomExtra.elm
│ ├── RoseTree.elm
│ ├── Shrink.elm
│ ├── Test.elm
│ └── Test
│ │ ├── Expectation.elm
│ │ ├── Fuzz.elm
│ │ ├── Html
│ │ ├── Descendant.elm
│ │ ├── Event.elm
│ │ ├── Internal
│ │ │ ├── ElmHtml
│ │ │ │ ├── Constants.elm
│ │ │ │ ├── Helpers.elm
│ │ │ │ ├── InternalTypes.elm
│ │ │ │ ├── Markdown.elm
│ │ │ │ ├── Query.elm
│ │ │ │ └── ToString.elm
│ │ │ └── Inert.elm
│ │ ├── Query.elm
│ │ ├── Query
│ │ │ └── Internal.elm
│ │ ├── Selector.elm
│ │ └── Selector
│ │ │ └── Internal.elm
│ │ ├── Internal.elm
│ │ ├── Internal
│ │ └── KernelConstants.elm
│ │ ├── Runner.elm
│ │ └── Runner
│ │ └── Failure.elm
└── tests
│ ├── .gitignore
│ ├── MakeTestRegistry.hs
│ ├── README.md
│ ├── elm.json
│ ├── src
│ ├── FloatWithinTests.elm
│ ├── FuzzerTests.elm
│ ├── Helpers.elm
│ ├── Main.elm
│ ├── Runner
│ │ ├── Log.elm
│ │ ├── String.elm
│ │ └── String
│ │ │ └── Format.elm
│ ├── RunnerTests.elm
│ ├── SeedTests.elm
│ ├── ShrinkTests.elm
│ ├── Test
│ │ └── Html
│ │ │ ├── EventTests.elm
│ │ │ ├── ExampleApp.elm
│ │ │ ├── ExampleAppTests.elm
│ │ │ ├── Query
│ │ │ ├── CustomNodeTests.elm
│ │ │ └── MarkdownTests.elm
│ │ │ ├── QueryTests.elm
│ │ │ └── SelectorTests.elm
│ └── Tests.elm
│ ├── test.sh
│ └── versions.dat
├── tests
├── .gitignore
├── browser-tests
│ ├── .gitignore
│ ├── AllHtmlEvents.elm
│ ├── elm.json
│ └── index.test.js
├── check-kernel-imports.js
├── elm.json
├── generate-globals.py
├── src
│ └── empty
├── sscce-tests
│ ├── .github
│ │ └── workflows
│ │ │ └── ci.yml
│ ├── .gitignore
│ ├── Cargo.lock
│ ├── Cargo.toml
│ ├── README.md
│ ├── bors.toml
│ ├── config.json
│ ├── embed-assets
│ │ ├── cert.pem
│ │ ├── elm-serverless
│ │ │ ├── .editorconfig
│ │ │ ├── .eslintignore
│ │ │ ├── .eslintrc
│ │ │ ├── .gitignore
│ │ │ ├── .npmignore
│ │ │ ├── CHANGELOG.md
│ │ │ ├── CODE_OF_CONDUCT.md
│ │ │ ├── CONTRIBUTING.md
│ │ │ ├── LICENSE
│ │ │ ├── README.md
│ │ │ ├── circle.yml
│ │ │ ├── demo
│ │ │ │ ├── README.md
│ │ │ │ ├── elm.json
│ │ │ │ ├── serverless.yml
│ │ │ │ ├── src
│ │ │ │ │ ├── Config
│ │ │ │ │ │ ├── API.elm
│ │ │ │ │ │ └── api.js
│ │ │ │ │ ├── Forms
│ │ │ │ │ │ ├── API.elm
│ │ │ │ │ │ └── api.js
│ │ │ │ │ ├── Hello
│ │ │ │ │ │ ├── API.elm
│ │ │ │ │ │ └── api.js
│ │ │ │ │ ├── Interop
│ │ │ │ │ │ ├── API.elm
│ │ │ │ │ │ └── api.js
│ │ │ │ │ ├── Logging.elm
│ │ │ │ │ ├── Pipelines
│ │ │ │ │ │ ├── API.elm
│ │ │ │ │ │ └── api.js
│ │ │ │ │ ├── Quoted
│ │ │ │ │ │ ├── API.elm
│ │ │ │ │ │ ├── Middleware.elm
│ │ │ │ │ │ ├── Models
│ │ │ │ │ │ │ └── Quote.elm
│ │ │ │ │ │ ├── Pipelines
│ │ │ │ │ │ │ └── Quote.elm
│ │ │ │ │ │ ├── Route.elm
│ │ │ │ │ │ ├── Types.elm
│ │ │ │ │ │ └── api.js
│ │ │ │ │ ├── Routing
│ │ │ │ │ │ ├── API.elm
│ │ │ │ │ │ └── api.js
│ │ │ │ │ └── SideEffects
│ │ │ │ │ │ ├── API.elm
│ │ │ │ │ │ └── api.js
│ │ │ │ └── webpack.config.js
│ │ │ ├── elm.json
│ │ │ ├── es-logo-small.png
│ │ │ ├── es-logo.png
│ │ │ ├── package.json
│ │ │ ├── scripts
│ │ │ │ ├── ci-elm-hack.sh
│ │ │ │ ├── stop-test-server.js
│ │ │ │ └── test-server.js
│ │ │ ├── src-bridge
│ │ │ │ ├── index.js
│ │ │ │ ├── logger.js
│ │ │ │ ├── normalize-headers.js
│ │ │ │ ├── pool.js
│ │ │ │ ├── request-handler.js
│ │ │ │ ├── response-handler.js
│ │ │ │ ├── validate.js
│ │ │ │ └── xmlhttprequest.js
│ │ │ ├── src
│ │ │ │ ├── Serverless.elm
│ │ │ │ └── Serverless
│ │ │ │ │ ├── Conn.elm
│ │ │ │ │ ├── Conn
│ │ │ │ │ ├── Body.elm
│ │ │ │ │ ├── Charset.elm
│ │ │ │ │ ├── IpAddress.elm
│ │ │ │ │ ├── KeyValueList.elm
│ │ │ │ │ ├── Pool.elm
│ │ │ │ │ ├── Request.elm
│ │ │ │ │ └── Response.elm
│ │ │ │ │ ├── Cors.elm
│ │ │ │ │ └── Plug.elm
│ │ │ ├── test
│ │ │ │ ├── bridge
│ │ │ │ │ ├── bridge-spec.js
│ │ │ │ │ ├── normalize-headers-spec.js
│ │ │ │ │ ├── pool-spec.js
│ │ │ │ │ ├── request-handler-spec.js
│ │ │ │ │ ├── response-handler-spec.js
│ │ │ │ │ ├── spy-logger.js
│ │ │ │ │ └── validate-spec.js
│ │ │ │ ├── demo
│ │ │ │ │ ├── config-spec.js
│ │ │ │ │ ├── forms-spec.js
│ │ │ │ │ ├── hello-spec.js
│ │ │ │ │ ├── interop-spec.js
│ │ │ │ │ ├── pipelines-spec.js
│ │ │ │ │ ├── quoted-spec.js
│ │ │ │ │ ├── request.js
│ │ │ │ │ ├── routing-spec.js
│ │ │ │ │ └── side-effects-spec.js
│ │ │ │ └── mocha.opts
│ │ │ └── tests
│ │ │ │ ├── Serverless
│ │ │ │ ├── Conn
│ │ │ │ │ ├── DecodeTests.elm
│ │ │ │ │ ├── EncodeTests.elm
│ │ │ │ │ ├── Fuzz.elm
│ │ │ │ │ ├── PoolTests.elm
│ │ │ │ │ └── Test.elm
│ │ │ │ └── ConnTests.elm
│ │ │ │ ├── TestHelpers.elm
│ │ │ │ ├── elm-doc-test.json
│ │ │ │ ├── elm-verify-examples.json
│ │ │ │ └── elm.json.elmupgrade
│ │ ├── key.key
│ │ └── run.js
│ ├── exit-codes.md
│ ├── src
│ │ ├── lib
│ │ │ ├── cli.rs
│ │ │ ├── config.rs
│ │ │ ├── find_suites.rs
│ │ │ ├── formatting.rs
│ │ │ ├── mod.rs
│ │ │ ├── server_pool.rs
│ │ │ └── suite.rs
│ │ └── main.rs
│ ├── suite
│ │ ├── compiler-tests
│ │ │ └── lambda-empty-record
│ │ │ │ ├── Main.elm
│ │ │ │ ├── elm.json
│ │ │ │ └── output.json
│ │ ├── debug
│ │ │ ├── equal-fails-with-fn
│ │ │ │ ├── Main.elm
│ │ │ │ ├── elm.json
│ │ │ │ └── output.json
│ │ │ ├── half-baked-log
│ │ │ │ ├── Main.elm
│ │ │ │ ├── elm.json
│ │ │ │ └── output.json
│ │ │ └── log
│ │ │ │ ├── Main.elm
│ │ │ │ ├── elm.json
│ │ │ │ └── output.json
│ │ ├── echo
│ │ │ ├── Main.elm
│ │ │ ├── elm.json
│ │ │ └── output.json
│ │ ├── hello-world
│ │ │ ├── Main.elm
│ │ │ ├── elm.json
│ │ │ └── output.json
│ │ ├── http
│ │ │ ├── hello-json
│ │ │ │ ├── Main.elm
│ │ │ │ ├── elm.json
│ │ │ │ └── output.json
│ │ │ └── hello-world
│ │ │ │ ├── Main.elm
│ │ │ │ ├── elm.json
│ │ │ │ └── output.json
│ │ ├── if-then-else
│ │ │ ├── Main.elm
│ │ │ ├── elm.json
│ │ │ └── output.json
│ │ ├── issues
│ │ │ ├── 1246
│ │ │ │ ├── Main.elm
│ │ │ │ ├── elm.json
│ │ │ │ └── output.json
│ │ │ ├── 1516
│ │ │ │ ├── Main.elm
│ │ │ │ ├── elm.json
│ │ │ │ └── output.json
│ │ │ ├── 1685
│ │ │ │ ├── Main.elm
│ │ │ │ ├── elm.json
│ │ │ │ └── output.json
│ │ │ ├── 1722
│ │ │ │ ├── Main.elm
│ │ │ │ ├── elm.json
│ │ │ │ └── output.json
│ │ │ ├── 1753
│ │ │ │ ├── Main.elm
│ │ │ │ ├── elm.json
│ │ │ │ └── output.json
│ │ │ ├── 1776
│ │ │ │ ├── Main.elm
│ │ │ │ ├── elm.json
│ │ │ │ └── output.json
│ │ │ ├── 1813
│ │ │ │ ├── Main.elm
│ │ │ │ ├── elm.json
│ │ │ │ └── output.json
│ │ │ ├── 1916
│ │ │ │ ├── Main.elm
│ │ │ │ ├── elm.json
│ │ │ │ └── output.json
│ │ │ └── 1964
│ │ │ │ ├── Main.elm
│ │ │ │ ├── elm.json
│ │ │ │ └── output.json
│ │ ├── kill
│ │ │ ├── Main.elm
│ │ │ ├── elm.json
│ │ │ └── output.json
│ │ ├── map-cmd
│ │ │ ├── Main.elm
│ │ │ ├── elm.json
│ │ │ └── output.json
│ │ ├── module-name-clash
│ │ │ ├── Main.elm
│ │ │ ├── Module1.elm
│ │ │ ├── README.md
│ │ │ ├── elm.json
│ │ │ └── output.json
│ │ ├── multiple-processes
│ │ │ ├── Main.elm
│ │ │ ├── elm.json
│ │ │ └── output.json
│ │ ├── multiple-subscriptions
│ │ │ ├── Main.elm
│ │ │ ├── elm.json
│ │ │ └── output.json
│ │ ├── numeric-package
│ │ │ ├── Main.elm
│ │ │ ├── elm.json
│ │ │ └── output.json
│ │ ├── parser
│ │ │ ├── README
│ │ │ ├── back-slash-char
│ │ │ │ ├── Main.elm
│ │ │ │ ├── elm.json
│ │ │ │ └── output.json
│ │ │ └── nested-module-record
│ │ │ │ ├── Main.elm
│ │ │ │ ├── Nested
│ │ │ │ └── Module.elm
│ │ │ │ ├── elm.json
│ │ │ │ └── output.json
│ │ ├── random
│ │ │ ├── Main.elm
│ │ │ ├── elm.json
│ │ │ └── output.json
│ │ ├── sleep
│ │ │ ├── Main.elm
│ │ │ ├── elm.json
│ │ │ └── output.json
│ │ ├── subscription-order
│ │ │ ├── Main.elm
│ │ │ ├── elm.json
│ │ │ └── output.json
│ │ ├── time
│ │ │ ├── every
│ │ │ │ ├── Main.elm
│ │ │ │ ├── elm.json
│ │ │ │ └── output.json
│ │ │ ├── here
│ │ │ │ ├── Main.elm
│ │ │ │ ├── elm.json
│ │ │ │ └── output.json
│ │ │ └── zone-name
│ │ │ │ ├── Main.elm
│ │ │ │ ├── elm.json
│ │ │ │ └── output.json
│ │ ├── update-loop
│ │ │ ├── Main.elm
│ │ │ ├── elm.json
│ │ │ └── output.json
│ │ └── util
│ │ │ └── Util
│ │ │ ├── Cmds.elm
│ │ │ ├── Http.elm
│ │ │ ├── Programs.elm
│ │ │ └── Subs.elm
│ └── update-json.js
├── tests
│ ├── FromElmTest
│ │ ├── Fuzz.elm
│ │ ├── Fuzz
│ │ │ └── Internal.elm
│ │ ├── Lazy.elm
│ │ ├── Lazy
│ │ │ └── List.elm
│ │ ├── MicroRandomExtra.elm
│ │ └── RoseTree.elm
│ └── Test
│ │ ├── Array.elm
│ │ ├── Basics.elm
│ │ ├── Bitwise.elm
│ │ ├── Bytes.elm
│ │ ├── Char.elm
│ │ ├── CodeGen.elm
│ │ ├── Dict.elm
│ │ ├── Equality.elm
│ │ ├── Html
│ │ └── Events.elm
│ │ ├── Json.elm
│ │ ├── List.elm
│ │ ├── Maybe.elm
│ │ ├── Result.elm
│ │ ├── Set.elm
│ │ ├── String.elm
│ │ └── Tuple.elm
└── vdom-tests
│ ├── .eslintignore
│ ├── .eslintrc.json
│ ├── .gitignore
│ ├── .prettierignore
│ ├── .prettierrc.json
│ ├── LICENSE
│ ├── bin.js
│ ├── elm-tooling.json
│ ├── elm.json
│ ├── index.html
│ ├── index.js
│ ├── package-lock.json
│ ├── package.json
│ ├── patch.js
│ ├── serve.json
│ ├── src
│ ├── ElmUi.elm
│ ├── KeyList.elm
│ ├── Main.elm
│ ├── OnlyHtml.elm
│ ├── Sandbox.elm
│ └── SandboxSimple.elm
│ └── tests
│ ├── elm
│ ├── App.elm
│ └── KitchenSink.elm
│ ├── helpers.js
│ ├── helpers.test.js
│ └── index.test.js
└── x.py
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on:
4 | push:
5 | branches:
6 | - staging
7 | - trying
8 | - master
9 |
10 | jobs:
11 | test:
12 | name: Test
13 | runs-on: ${{ matrix.os }}
14 | strategy:
15 | fail-fast: false
16 | matrix:
17 | os:
18 | - ubuntu-latest
19 |
20 | steps:
21 | - uses: actions/checkout@v1
22 |
23 | - uses: actions-rs/toolchain@v1
24 | with:
25 | profile: minimal
26 | toolchain: stable
27 |
28 | - uses: actions/setup-python@v2
29 | with:
30 | python-version: '3.x'
31 | - name: Install python dependencies
32 | run: python -m pip install --upgrade yapf~=0.31.0 flake8~=3.9.0
33 |
34 | - uses: mpizenberg/elm-tooling-action@b6665b9d55111b51d09574b4338883ab572d100f
35 | with:
36 | cache-key: elm-home-${{ matrix.os }}
37 | elm: '0.19.1'
38 | elm-format: '0.8.5'
39 | elm-json: '0.2.10'
40 |
41 | - name: Create local bin dir and add it to PATH.
42 | run: |
43 | mkdir -p "$HOME/.local/bin"
44 | echo "$HOME/.local/bin" >> $GITHUB_PATH
45 |
46 | - name: Install elm-test-rs
47 | run: |
48 | cd "$HOME/.local/bin"
49 | wget https://github.com/mpizenberg/elm-test-rs/releases/download/v1.0.0-beta/elm-test-rs_linux.tar.gz
50 | tar -xvf elm-test-rs_linux.tar.gz
51 | rm elm-test-rs_linux.tar.gz
52 |
53 | - run: ./x.py install
54 | - run: ./init.py
55 |
56 | - run: ./x.py check
57 | - run: ./x.py test
58 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | elm-stuff/
2 | node_modules/
3 | /package-lock.json
4 |
--------------------------------------------------------------------------------
/CONTRIBUTING:
--------------------------------------------------------------------------------
1 | Quick Installation Guide for another-elm/std
2 | ============================================
3 |
4 | Contributions are very welcome, currently we do not have any explicit
5 | guidelines.
6 |
7 | Getting started
8 | ---------------
9 |
10 | After cloning the repository run `$ ./x.py install` which will install some
11 | dependencies and check other dependencies are installed. If it runs
12 | successfully you should be good to go.
13 |
14 | Tools
15 |
16 | - `$ ./x.py tidy` runs formatting and automatic eslint fixing.
17 | - `$ ./x.py check` runs all the static analysis tools we have.
18 | - `$ ./init.py cd tests && elm-test --compiler ../another-elm` runs unit tests.
19 | We will hopefully get a nice python sub-command for testing soon.
20 |
21 | Acknowledgements
22 | ----------------
23 |
24 | The vast majority of the code in another-elm is derived from the relevant elm/*
25 | packages.
26 |
27 | The documentation of another-elm is inspired by that of [musl].
28 |
29 | [musl]: https://musl.libc.org/
30 |
--------------------------------------------------------------------------------
/INSTALL:
--------------------------------------------------------------------------------
1 | Quick Installation Guide for another-elm
2 | ========================================
3 |
4 |
5 | another-elm comes with a wrapper script of the same name. The wrapper should be
6 | a drop in replacement for the offical elm compiler.
7 |
8 |
9 | Prerequisites
10 | -------------
11 |
12 | The wrapper script is written in python, a non-eol needs to be installed to run
13 | the wrapper. The official elm compiler must also be installed.
14 |
15 |
16 | Supported Elm Versions
17 | ----------------------
18 |
19 | We support the latest version of elm, older versions may be supported but that
20 | support may be removed at any time.
21 |
22 |
23 | Build and Installation Procedure
24 | --------------------------------
25 |
26 | To install another-elm to "~/.local/bin":
27 |
28 | ANOTHER_ELM_DIR="${XDG_DATA_HOME:-~/.local/share}/another-elm"
29 | mkdir -p "$ANOTHER_ELM_DIR"
30 | cd "$ANOTHER_ELM_DIR"
31 | git clone https://github.com/another-elm/std
32 | cd std
33 | ./init.py
34 |
35 |
36 | Checking for Successful Installation
37 | ------------------------------------
38 |
39 | Currently it is hard to work out if the installation worked correctly. In the
40 | future we will automate this. For now, here is a usefull test: if the compiler
41 | generates javascript contains "$elm$core$Platform$Raw$Scheduler" then
42 | another-elm has been correctly installed.
43 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2014-present Evan Czaplicki
2 |
3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4 |
5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6 |
7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8 |
9 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10 |
11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12 |
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 |
2 | another-elm/std
3 |
4 | Another implementation of the elm standard libraries. Contributions are very
5 | welcome, currently we are aiming for maximum compatibility with the offical
6 | elm/* packages.
7 |
8 | See
9 |
10 | ./NEWS: To read about the development of this library
11 | ./LICENSE: For the BSD-3-Clause licence.
12 | ./INSTALL: For installation details.
13 | ./CONTRIBUTING: To get involved and for our acknowledgements.
14 |
15 |
16 | We will leave you with Tom Odell's `Another elm':
17 |
18 | And I'd sing a song, that'd be just ours
19 | But I sang 'em all to another heart
20 | And I wanna cry I wanna learn to love
21 | But all my pull-requests got batched
22 |
23 | On another elm, another elm
24 | All my tears have been used up
25 | On another elm, another elm
26 | All my tears have been used up
27 | On another elm, another elm
28 | All my tears have been used up
29 |
--------------------------------------------------------------------------------
/TODO:
--------------------------------------------------------------------------------
1 | TODO list
2 | =========
3 |
4 | Tests
5 | -----
6 |
7 | - Merging of exports.
8 | - Check Basics.isDebug enables dead code elimination.
9 | - Have a test for Elm.Kernel.List.nilKey
10 |
--------------------------------------------------------------------------------
/_file/.gitignore:
--------------------------------------------------------------------------------
1 | elm-stuff
--------------------------------------------------------------------------------
/_file/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2018-present, Evan Czaplicki
2 |
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 |
8 | * Redistributions of source code must retain the above copyright
9 | notice, this list of conditions and the following disclaimer.
10 |
11 | * Redistributions in binary form must reproduce the above
12 | copyright notice, this list of conditions and the following
13 | disclaimer in the documentation and/or other materials provided
14 | with the distribution.
15 |
16 | * Neither the name of Evan Czaplicki nor the names of other
17 | contributors may be used to endorse or promote products derived
18 | from this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 |
--------------------------------------------------------------------------------
/_file/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "package",
3 | "name": "elm/file",
4 | "summary": "Select files. Download files. Work with file content.",
5 | "license": "BSD-3-Clause",
6 | "version": "1.0.5",
7 | "exposed-modules": [
8 | "File",
9 | "File.Select",
10 | "File.Download"
11 | ],
12 | "elm-version": "0.19.0 <= v < 0.20.0",
13 | "dependencies": {
14 | "elm/bytes": "1.0.0 <= v < 2.0.0",
15 | "elm/core": "1.0.1 <= v < 2.0.0",
16 | "elm/json": "1.1.0 <= v < 2.0.0",
17 | "elm/time": "1.0.0 <= v < 2.0.0"
18 | },
19 | "test-dependencies": {}
20 | }
--------------------------------------------------------------------------------
/browser/.gitignore:
--------------------------------------------------------------------------------
1 | elm-stuff
--------------------------------------------------------------------------------
/browser/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2017-present Evan Czaplicki
2 |
3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4 |
5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6 |
7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8 |
9 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10 |
11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12 |
--------------------------------------------------------------------------------
/browser/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "package",
3 | "name": "elm/browser",
4 | "summary": "Run Elm in browsers, with access to browser history for single-page apps (SPAs)",
5 | "license": "BSD-3-Clause",
6 | "version": "1.0.2",
7 | "exposed-modules": {
8 | "Browser": [
9 | "Browser",
10 | "Browser.Dom",
11 | "Browser.Events",
12 | "Browser.Navigation"
13 | ],
14 | "URL": [
15 | "Url",
16 | "Url.Builder",
17 | "Url.Parser",
18 | "Url.Parser.Query"
19 | ]
20 | },
21 | "elm-version": "0.19.0 <= v < 0.20.0",
22 | "dependencies": {
23 | "elm/core": "1.0.0 <= v < 2.0.0",
24 | "elm/html": "1.0.0 <= v < 2.0.0",
25 | "elm/json": "1.0.0 <= v < 2.0.0",
26 | "elm/time": "1.0.0 <= v < 2.0.0"
27 | },
28 | "test-dependencies": {}
29 | }
30 |
--------------------------------------------------------------------------------
/browser/examples/README.md:
--------------------------------------------------------------------------------
1 | # Examples
2 |
3 | To compile these examples locally, run the following terminal commands:
4 |
5 | ```
6 | git clone https://github.com/elm/browser.git
7 | cd browser/examples
8 | elm reactor
9 | ```
10 |
11 | Now go to [`http://localhost:8000`](http://localhost:8000) and navigate to whatever Elm file you want to see.
12 |
--------------------------------------------------------------------------------
/browser/examples/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | "src"
5 | ],
6 | "elm-version": "0.19.1",
7 | "dependencies": {
8 | "direct": {
9 | "elm/browser": "1.0.2",
10 | "elm/core": "1.0.2",
11 | "elm/html": "1.0.0",
12 | "elm/json": "1.1.3"
13 | },
14 | "indirect": {
15 | "elm/time": "1.0.0",
16 | "elm/url": "1.0.0",
17 | "elm/virtual-dom": "1.0.2"
18 | }
19 | },
20 | "test-dependencies": {
21 | "direct": {},
22 | "indirect": {}
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/browser/notes/capture-vs-bubble.md:
--------------------------------------------------------------------------------
1 | Events flow through the DOM in two phases:
2 |
3 |
4 | ```
5 | Capture Bubble
6 | ↓ ↑
7 | ┌──────↓──────────↑──────┐
8 | │ ↓ Body ↑ │
9 | │ ┌────↓──────────↑────┐ │
10 | │ │ ↓ Div ↑ │ │
11 | │ │ ┌──↓──────────↑──┐ │ │
12 | │ │ │ Button │ │ │
13 | │ │ └────────────────┘ │ │
14 | │ └────────────────────┘ │
15 | └────────────────────────┘
16 | ```
17 |
18 |
19 | In the old times, Microsoft only had `Bubble` and Netscape only had `Capture`. It was not ideal.
20 |
21 | Today browsers support both, and **`Bubble` is the default** for
22 | `addEventListener` in JavaScript and for all the functions in
23 | [`Html.Events`](http://package.elm-lang.org/packages/elm-lang/html/latest/Html-Events).
24 |
25 | It is extremely difficult to get `Capture` to behave predictably, especially if you are doing any `stopPropagation` tricks. It does not seem to be a great idea, and it seems too late to remove it.
26 |
--------------------------------------------------------------------------------
/browser/notes/properties-vs-attributes.md:
--------------------------------------------------------------------------------
1 | # Properties vs. Attributes
2 |
3 | When you are working with HTML, you can have DOM nodes like `
`. And you can add *attributes* to those DOM nodes, like ``.
4 |
5 | When you are creating DOM nodes in JavaScript, there are two ways to add attributes like this:
6 |
7 | 1. **Attributes** — You can use the `setAttribute` function. So adding a class attribute would look like this: `domNode.setAttribute('class', 'user-info')`.
8 |
9 | 2. **Properties** — JavaScript often exposes an alternate way to set these attributes. Another way to add a class attribute would be like this: `domNode.className = 'user-info'`
10 |
11 | Notice that the attribute is called `class` but the property is called `className`. This is because `class` is a reserved word in JavaScript. Point is, **attributes and properties do not always match up.**
12 |
13 | It is actually a bit crazier than that though. **Sometimes an attribute exists, but there is no corresponding property.** For example, as of this writing the `webkit-playsinline` can be added with `setAttribute`, but there is no corresponding property. And with SVG, you cannot use properties at all, you must to use `setAttributeNS` for everything.
14 |
15 | With all the corner cases here, it makes sense to have access to both approaches.
--------------------------------------------------------------------------------
/browser/src/Browser/Internal.elm:
--------------------------------------------------------------------------------
1 | module Browser.Internal exposing (..)
2 |
3 | import Platform.Unstable.Impure as Impure
4 | import Time
5 | import Elm.Kernel.Basics
6 | import Elm.Kernel.Browser
7 |
8 | rafTask : Platform.Task never Time.Posix
9 | rafTask =
10 | AsyncAction
11 | { then_ = \doneCallback ->
12 | Impure.fromFunction rawRaf (Impure.toFunction (Time.millisToPosix >> Ok >> Value >> doneCallback))
13 | }
14 | |> wrapTask
15 |
16 |
17 | type RawTask err val
18 | = Value (Result err val)
19 | | AsyncAction (Future err val)
20 |
21 |
22 | type alias Future err val =
23 | { then_ : (RawTask err val -> Impure.Action ()) -> Impure.Action TryAbortAction }
24 |
25 |
26 | type alias TryAbortAction =
27 | Impure.Action ()
28 |
29 |
30 | {-| Create a task that executes a non pure function
31 | -}
32 | execImpure : Impure.Action a -> Platform.Task never a
33 | execImpure action =
34 | AsyncAction
35 | { then_ =
36 | \callback ->
37 | action
38 | |> Impure.andThen (Ok >> Value >> callback)
39 | |> Impure.map (\() -> Impure.resolve ())
40 | }
41 | |> wrapTask
42 |
43 |
44 | {-| Create a task that executes a non pure function
45 | -}
46 | fromFunction : Impure.Function a b -> a -> Platform.Task never b
47 | fromFunction func arg =
48 | execImpure (Impure.fromFunction func arg)
49 |
50 |
51 | wrapTask : RawTask e o -> Platform.Task e o
52 | wrapTask =
53 | Elm.Kernel.Basics.fudgeType
54 |
55 |
56 | unwrapTask : Platform.Task e o -> RawTask e o
57 | unwrapTask =
58 | Elm.Kernel.Basics.fudgeType
59 |
60 |
61 | rawRaf : Impure.Function (Impure.Function Int ()) TryAbortAction
62 | rawRaf =
63 | Elm.Kernel.Browser.rawRaf
64 |
--------------------------------------------------------------------------------
/browser/src/Elm/Kernel/Url.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | import Maybe exposing (Just, Nothing)
4 |
5 | */
6 |
7 | function _Url_percentEncode(string) {
8 | return encodeURIComponent(string);
9 | }
10 |
11 | function _Url_percentDecode(string) {
12 | try {
13 | return __Maybe_Just(decodeURIComponent(string));
14 | } catch {
15 | return __Maybe_Nothing;
16 | }
17 | }
18 |
19 | /* ESLINT GLOBAL VARIABLES
20 | *
21 | * Do not edit below this line as it is generated by tests/generate-globals.py
22 | */
23 |
24 | /* eslint no-unused-vars: ["error", { "varsIgnorePattern": "_Url_.*" }] */
25 |
26 | /* global __Maybe_Just, __Maybe_Nothing */
27 |
--------------------------------------------------------------------------------
/browser/src/Url/Parser/Internal.elm:
--------------------------------------------------------------------------------
1 | module Url.Parser.Internal exposing
2 | ( QueryParser(..)
3 | )
4 |
5 |
6 | import Dict
7 |
8 |
9 | type QueryParser a =
10 | Parser (Dict.Dict String (List String) -> a)
11 |
--------------------------------------------------------------------------------
/core/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "package",
3 | "name": "elm/core",
4 | "summary": "Elm's standard libraries",
5 | "license": "BSD-3-Clause",
6 | "version": "1.0.5",
7 | "exposed-modules": {
8 | "Primitives": [
9 | "Basics",
10 | "String",
11 | "Char",
12 | "Bitwise",
13 | "Tuple",
14 | "Bytes",
15 | "Bytes.Encode",
16 | "Bytes.Decode"
17 | ],
18 | "Collections": [
19 | "List",
20 | "Dict",
21 | "Set",
22 | "Array"
23 | ],
24 | "Error Handling": [
25 | "Maybe",
26 | "Result"
27 | ],
28 | "Debug": [
29 | "Debug"
30 | ],
31 | "Effects": [
32 | "Platform.Cmd",
33 | "Platform.Sub",
34 | "Platform",
35 | "Process",
36 | "Task",
37 | "Time",
38 | "Random"
39 | ],
40 | "Network": [
41 | "File",
42 | "Http",
43 | "HttpV1"
44 | ],
45 | "Parsing": [
46 | "Parser",
47 | "Parser.Advanced"
48 | ],
49 | "Unstable": [
50 | "Platform.Unstable.Impure",
51 | "Platform.Unstable.Effect",
52 | "Platform.Unstable.Iterable",
53 | "Platform.Unstable.SubManager"
54 | ]
55 | },
56 | "elm-version": "0.19.0 <= v < 0.20.0",
57 | "dependencies": {
58 | "elm/json": "1.1.3 <= v < 2.0.0"
59 | },
60 | "test-dependencies": {}
61 | }
62 |
--------------------------------------------------------------------------------
/core/src/Elm/Kernel/Basics.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | import Elm.Kernel.Debug exposing (crash)
4 |
5 | */
6 |
7 | // MATH
8 |
9 | const _Basics_pow = F2(Math.pow);
10 |
11 | const _Basics_cos = Math.cos;
12 | const _Basics_sin = Math.sin;
13 | const _Basics_tan = Math.tan;
14 | const _Basics_acos = Math.acos;
15 | const _Basics_asin = Math.asin;
16 | const _Basics_atan = Math.atan;
17 | const _Basics_atan2 = F2(Math.atan2);
18 |
19 | const _Basics_ceiling = Math.ceil;
20 | const _Basics_floor = Math.floor;
21 | const _Basics_round = Math.round;
22 | const _Basics_sqrt = Math.sqrt;
23 | const _Basics_log = Math.log;
24 |
25 | const _Basics_modBy0 = () => __Debug_crash(11);
26 |
27 | const _Basics_fudgeType = (x) => x;
28 |
29 | const _Basics_isDebug__DEBUG = true;
30 | const _Basics_isDebug__PROD = false;
31 |
32 | /* ESLINT GLOBAL VARIABLES
33 | *
34 | * Do not edit below this line as it is generated by tests/generate-globals.py
35 | */
36 |
37 | /* eslint no-unused-vars: ["error", { "varsIgnorePattern": "_Basics_.*" }] */
38 |
39 | /* global __Debug_crash */
40 |
--------------------------------------------------------------------------------
/core/src/Elm/Kernel/Char.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | import Elm.Kernel.Utils exposing (chr)
4 |
5 | */
6 |
7 | function _Char_toCode(char) {
8 | return char.codePointAt(0);
9 | }
10 |
11 | function _Char_fromCode(code) {
12 | return __Utils_chr(code < 0 || code > 0x10ffff ? "\uFFFD" : String.fromCodePoint(code));
13 | }
14 |
15 | function _Char_toUpper(char) {
16 | return __Utils_chr(char.toUpperCase());
17 | }
18 |
19 | function _Char_toLower(char) {
20 | return __Utils_chr(char.toLowerCase());
21 | }
22 |
23 | function _Char_toLocaleUpper(char) {
24 | return __Utils_chr(char.toLocaleUpperCase());
25 | }
26 |
27 | function _Char_toLocaleLower(char) {
28 | return __Utils_chr(char.toLocaleLowerCase());
29 | }
30 |
31 | /* ESLINT GLOBAL VARIABLES
32 | *
33 | * Do not edit below this line as it is generated by tests/generate-globals.py
34 | */
35 |
36 | /* eslint no-unused-vars: ["error", { "varsIgnorePattern": "_Char_.*" }] */
37 |
38 | /* global __Utils_chr */
39 |
--------------------------------------------------------------------------------
/core/src/Elm/Kernel/Time.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | import Elm.Kernel.Utils exposing (Tuple0)
4 |
5 | */
6 |
7 | function _Time_rawNow() {
8 | return Date.now();
9 | }
10 |
11 | const _Time_setInterval = (interval) => (onEffects) =>
12 | setInterval(() => {
13 | const now = _Time_rawNow();
14 | onEffects(now);
15 | }, interval - (_Time_rawNow() % interval));
16 |
17 | const _Time_clearInterval = (key) => {
18 | clearInterval(key);
19 | return __Utils_Tuple0;
20 | };
21 |
22 | const _Time_getTimezoneOffset = () => new Date().getTimezoneOffset();
23 |
24 | const _Time_getZoneName = () => Intl.DateTimeFormat().resolvedOptions().timeZone;
25 |
26 | /* ESLINT GLOBAL VARIABLES
27 | *
28 | * Do not edit below this line as it is generated by tests/generate-globals.py
29 | */
30 |
31 | /* eslint no-unused-vars: ["error", { "varsIgnorePattern": "_Time_.*" }] */
32 |
33 | /* global __Utils_Tuple0 */
34 |
--------------------------------------------------------------------------------
/core/src/HttpV1/Internal.elm:
--------------------------------------------------------------------------------
1 | module HttpV1.Internal exposing
2 | ( RawRequest
3 | , Request(..)
4 | )
5 |
6 | import Basics exposing (..)
7 | import Http
8 | import Maybe exposing (Maybe)
9 | import String exposing (String)
10 |
11 |
12 | type Request e a
13 | = Request (RawRequest e a)
14 |
15 |
16 | type alias RawRequest e a =
17 | { method : String
18 | , headers : List Http.Header
19 | , url : String
20 | , body : Http.Body
21 | , expect : Http.Resolver e a
22 | , timeout : Maybe Float
23 | , withCredentials : Bool
24 | }
25 |
--------------------------------------------------------------------------------
/core/src/Platform/Unstable/Channel.elm:
--------------------------------------------------------------------------------
1 | module Platform.Unstable.Channel exposing (Receiver, recv)
2 |
3 | import Basics exposing (..)
4 | import Elm.Kernel.Channel
5 | import Maybe exposing (Maybe(..))
6 | import Platform.Unstable.Impure as Impure
7 | import Platform.Unstable.Task as RawTask
8 | import Result exposing (Result(..))
9 |
10 |
11 | type Receiver msg
12 | = Receiver
13 |
14 |
15 | {-| -}
16 | recv : Receiver msg -> RawTask.Task never msg
17 | recv chl =
18 | RawTask.AsyncAction
19 | { then_ =
20 | \doneCallback ->
21 | let
22 | onMsg : msg -> Impure.Action ()
23 | onMsg msg =
24 | doneCallback (msg |> Ok |> RawTask.Value)
25 | in
26 | Impure.fromFunction (rawRecv chl) (Impure.toFunction onMsg)
27 | }
28 |
29 |
30 | rawRecv : Receiver msg -> Impure.Function (Impure.Function msg ()) RawTask.TryAbortAction
31 | rawRecv =
32 | Elm.Kernel.Channel.rawRecv
33 |
--------------------------------------------------------------------------------
/core/src/Platform/Unstable/Effect2.elm:
--------------------------------------------------------------------------------
1 | module Platform.Unstable.Effect2 exposing (UpdateMetadata(..))
2 |
3 | {-| It is not clear to me why this needs to exist.
4 |
5 | Without this (and the import in the Platform kernel module) we get a ICE.
6 |
7 | -}
8 |
9 |
10 | type UpdateMetadata
11 | = SyncUpdate
12 | | AsyncUpdate
13 |
--------------------------------------------------------------------------------
/html/.gitignore:
--------------------------------------------------------------------------------
1 | elm-stuff
--------------------------------------------------------------------------------
/html/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2017-present Evan Czaplicki
2 |
3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4 |
5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6 |
7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8 |
9 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10 |
11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12 |
--------------------------------------------------------------------------------
/html/README.md:
--------------------------------------------------------------------------------
1 | # HTML
2 |
3 | Quickly render HTML in Elm.
4 |
5 |
6 | ## Examples
7 |
8 | The HTML part of an Elm program looks something like this:
9 |
10 | ```elm
11 | import Html exposing (Html, button, div, text)
12 | import Html.Events exposing (onClick)
13 |
14 | type Msg = Increment | Decrement
15 |
16 | view : Int -> Html Msg
17 | view count =
18 | div []
19 | [ button [ onClick Decrement ] [ text "-" ]
20 | , div [] [ text (String.fromInt count) ]
21 | , button [ onClick Increment ] [ text "+" ]
22 | ]
23 | ```
24 |
25 | If you call `view 42` you get something like this:
26 |
27 | ```html
28 |
29 |
30 |
42
31 |
32 |
33 | ```
34 |
35 | This snippet comes from a complete example. You can play with it online [here](https://elm-lang.org/examples/buttons) and read how it works [here](https://guide.elm-lang.org/architecture/user_input/buttons.html).
36 |
37 | You can play with a bunch of other examples [here](https://elm-lang.org/examples).
38 |
39 |
40 | ## Learn More
41 |
42 | **Definitely read through [guide.elm-lang.org](https://guide.elm-lang.org/) to understand how this all works!** The section on [The Elm Architecture](https://guide.elm-lang.org/architecture/index.html) is particularly helpful.
43 |
44 |
45 | ## Implementation
46 |
47 | This library is backed by [elm/virtual-dom](https://package.elm-lang.org/packages/elm/virtual-dom/latest/) which handles the dirty details of rendering DOM nodes quickly. You can read some blog posts about it here:
48 |
49 | - [Blazing Fast HTML, Round Two](https://elm-lang.org/blog/blazing-fast-html-round-two)
50 | - [Blazing Fast HTML](https://elm-lang.org/blog/blazing-fast-html)
51 |
--------------------------------------------------------------------------------
/html/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "package",
3 | "name": "elm/browser",
4 | "summary": "Fast HTML, rendered with virtual DOM diffing",
5 | "license": "BSD-3-Clause",
6 | "version": "1.0.0",
7 | "exposed-modules": {
8 | "Virtual Dom": [
9 | "VirtualDom"
10 | ],
11 | "HTML": [
12 | "Html",
13 | "Html.Attributes",
14 | "Html.Events"
15 | ],
16 | "Optimize": [
17 | "Html.Keyed",
18 | "Html.Lazy"
19 | ]
20 | },
21 | "elm-version": "0.19.0 <= v < 0.20.0",
22 | "dependencies": {
23 | "elm/core": "1.0.0 <= v < 2.0.0",
24 | "elm/json": "1.0.0 <= v < 2.0.0",
25 | "elm/time": "1.0.0 <= v < 2.0.0"
26 | },
27 | "test-dependencies": {}
28 | }
29 |
--------------------------------------------------------------------------------
/html/src/Html/Keyed.elm:
--------------------------------------------------------------------------------
1 | module Html.Keyed exposing
2 | ( node
3 | , ol
4 | , ul
5 | )
6 | {-| A keyed node helps optimize cases where children are getting added, moved,
7 | removed, etc. Common examples include:
8 |
9 | - The user can delete items from a list.
10 | - The user can create new items in a list.
11 | - You can sort a list based on name or date or whatever.
12 |
13 | When you use a keyed node, every child is paired with a string identifier. This
14 | makes it possible for the underlying diffing algorithm to reuse nodes more
15 | efficiently.
16 |
17 | # Keyed Nodes
18 | @docs node
19 |
20 | # Commonly Keyed Nodes
21 | @docs ol, ul
22 | -}
23 |
24 |
25 | import Html exposing (Attribute, Html)
26 | import VirtualDom
27 |
28 |
29 | {-| Works just like `Html.node`, but you add a unique identifier to each child
30 | node. You want this when you have a list of nodes that is changing: adding
31 | nodes, removing nodes, etc. In these cases, the unique identifiers help make
32 | the DOM modifications more efficient.
33 | -}
34 | node : String -> List (Attribute msg) -> List ( String, Html msg ) -> Html msg
35 | node =
36 | VirtualDom.keyedNode
37 |
38 |
39 | {-|-}
40 | ol : List (Attribute msg) -> List ( String, Html msg ) -> Html msg
41 | ol =
42 | node "ol"
43 |
44 |
45 | {-|-}
46 | ul : List (Attribute msg) -> List ( String, Html msg ) -> Html msg
47 | ul =
48 | node "ul"
49 |
--------------------------------------------------------------------------------
/json/.gitignore:
--------------------------------------------------------------------------------
1 | elm-stuff/
2 | /artifacts.dat
3 | /docs.json
4 | /tests/.elm
5 |
--------------------------------------------------------------------------------
/json/.travis.yml:
--------------------------------------------------------------------------------
1 | language: elm
2 |
3 | elm:
4 | - latest
5 |
6 | elm_test: latest
7 |
8 | elm_format: latest
9 |
10 | script:
11 | - bash tests/run-tests.sh
12 |
--------------------------------------------------------------------------------
/json/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2014-present Evan Czaplicki
2 |
3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4 |
5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6 |
7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8 |
9 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10 |
11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12 |
--------------------------------------------------------------------------------
/json/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "package",
3 | "name": "elm/json",
4 | "summary": "Encode and decode JSON values",
5 | "license": "BSD-3-Clause",
6 | "version": "1.1.3",
7 | "exposed-modules": [
8 | "Json.Decode",
9 | "Json.Encode"
10 | ],
11 | "elm-version": "0.19.0 <= v < 0.20.0",
12 | "dependencies": {
13 | "elm/core": "1.0.0 <= v < 2.0.0"
14 | },
15 | "test-dependencies": {}
16 | }
--------------------------------------------------------------------------------
/json/src/Json/Internal.elm:
--------------------------------------------------------------------------------
1 | module Json.Internal exposing (..)
2 |
3 | import Platform.Unstable.Effect as Effect
4 |
5 |
6 | type Value
7 | = Value Effect.RawJsObject
8 |
9 |
10 | unwrap : Value -> Effect.RawJsObject
11 | unwrap (Value raw) =
12 | raw
13 |
--------------------------------------------------------------------------------
/make-pkg.sh:
--------------------------------------------------------------------------------
1 | #! /bin/bash
2 |
3 | set -u
4 |
5 | ## Make a simple elm app
6 |
7 | # Why do this? If we run `elm make` in the elm/json package with an empty
8 | # $ELM_HOME we get strange compiler ICE (that does not go away until we delete
9 | # $ELM_HOME). This probably happens because elm/json has a circular dependancy
10 | # on itself via elm/core which must confuse the compiler.
11 | (
12 | cd "$(git rev-parse --show-toplevel)/tests/sscce-tests/suite/hello-world"
13 | another-elm make Main.elm --output /dev/null 1>/dev/null 2>/dev/null || true
14 | )
15 |
16 | ## Make package
17 |
18 | random_suffix=$(another-elm -Z --print-random-suffix)
19 | sed_in_elm_files="find ./ -type f -name "*.elm" -exec sed -i -e"
20 |
21 | $sed_in_elm_files "s/^import Elm\.Kernel\./-- UNDO import Elm.Kernel./g" {} \;
22 | $sed_in_elm_files "s/Platform\.Unstable\./Platform.Unstable${random_suffix}./g" {} \;
23 |
24 | another-elm make
25 | code=$?
26 |
27 | $sed_in_elm_files "s/-- UNDO import Elm\.Kernel\./import Elm.Kernel./g" {} \;
28 | $sed_in_elm_files "s/Platform\.Unstable${random_suffix}\./Platform.Unstable./g" {} \;
29 |
30 | exit $code
31 |
--------------------------------------------------------------------------------
/markdown/.gitignore:
--------------------------------------------------------------------------------
1 | elm-stuff
--------------------------------------------------------------------------------
/markdown/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2014, Evan Czaplicki
2 |
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 |
8 | * Redistributions of source code must retain the above copyright
9 | notice, this list of conditions and the following disclaimer.
10 |
11 | * Redistributions in binary form must reproduce the above
12 | copyright notice, this list of conditions and the following
13 | disclaimer in the documentation and/or other materials provided
14 | with the distribution.
15 |
16 | * Neither the name of Evan Czaplicki nor the names of other
17 | contributors may be used to endorse or promote products derived
18 | from this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 |
--------------------------------------------------------------------------------
/markdown/README.md:
--------------------------------------------------------------------------------
1 | # Markdown in Elm
2 |
3 | This package is for markdown parsing and rendering. It is based on the [marked][] project
4 | which focuses on speed.
5 |
6 | [marked]: https://github.com/chjj/marked
7 |
8 | ## Basic Usage
9 |
10 | ```elm
11 | content : Html msg
12 | content =
13 | Markdown.toHtml [class "content"] """
14 |
15 | # Apple Pie Recipe
16 |
17 | 1. Invent the universe.
18 | 2. Bake an apple pie.
19 |
20 | """
21 | ```
22 |
23 | **Warning:** Calling `Markdown.toHtml` parses the whole block, so try not to
24 | call it for no reason. In the `content` example above we only have to parse
25 | the text once, but if we put it in a function we may be doing a lot of
26 | unnecessary parsing.
27 |
28 |
29 | ## Code Blocks
30 |
31 | For highlighting any code blocks, the package relies on the
32 | [highlight.js](https://highlightjs.org/) project. So if you want to
33 | see highlighting of code blocks in the rendering result, you need to
34 | make sure that your page/app binds a version of that library
35 | (supporting the languages you want to handle) to `window.hljs` in
36 | Javascript. [This is how package.elm-lang.org does
37 | that.](https://github.com/elm/package.elm-lang.org/blob/e0b7aa4282038475612722ff7a57195866f8645b/backend/ServeFile.hs#L54)
38 |
39 |
--------------------------------------------------------------------------------
/markdown/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "package",
3 | "name": "elm-explorations/markdown",
4 | "summary": "Fast markdown parsing and rendering",
5 | "license": "BSD-3-Clause",
6 | "version": "1.0.0",
7 | "exposed-modules": [
8 | "Markdown"
9 | ],
10 | "elm-version": "0.19.0 <= v < 0.20.0",
11 | "dependencies": {
12 | "elm/core": "1.0.0 <= v < 2.0.0",
13 | "elm/html": "1.0.0 <= v < 2.0.0"
14 | },
15 | "test-dependencies": {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "devDependencies": {
3 | "@types/jest": "27.0.2",
4 | "elm": "latest-0.19.1",
5 | "elm-test": "latest-0.19.1",
6 | "jest": "27.3.1",
7 | "prettier": "2",
8 | "xo": "0.38"
9 | },
10 | "xo": {
11 | "envs": [
12 | "browser",
13 | "jest"
14 | ],
15 | "prettier": true,
16 | "space": true,
17 | "ignores": [
18 | "markdown/**",
19 | "tests/sscce-tests/**",
20 | "tests/vdom-tests/**",
21 | "test/**"
22 | ],
23 | "rules": {
24 | "camelcase": "off",
25 | "unicorn/filename-case": "off",
26 | "unicorn/no-abusive-eslint-disable": "warn",
27 | "new-cap": "off",
28 | "capitalized-comments": "off",
29 | "no-new-object": "off",
30 | "no-undef": [
31 | "error",
32 | {
33 | "typeof": false
34 | }
35 | ]
36 | },
37 | "globals": [
38 | "F2",
39 | "F3",
40 | "F4",
41 | "F5",
42 | "F6",
43 | "F7",
44 | "F8",
45 | "F9",
46 | "A2",
47 | "A3",
48 | "A4"
49 | ]
50 | },
51 | "prettier": {
52 | "printWidth": 100,
53 | "useTabs": false,
54 | "trailingComma": "es5",
55 | "singleQuote": false,
56 | "bracketSpacing": true
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/svg/.gitignore:
--------------------------------------------------------------------------------
1 | elm-stuff
--------------------------------------------------------------------------------
/svg/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2014-present, Evan Czaplicki
2 |
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 |
8 | * Redistributions of source code must retain the above copyright
9 | notice, this list of conditions and the following disclaimer.
10 |
11 | * Redistributions in binary form must reproduce the above
12 | copyright notice, this list of conditions and the following
13 | disclaimer in the documentation and/or other materials provided
14 | with the distribution.
15 |
16 | * Neither the name of Evan Czaplicki nor the names of other
17 | contributors may be used to endorse or promote products derived
18 | from this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 |
--------------------------------------------------------------------------------
/svg/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "package",
3 | "name": "elm/svg",
4 | "summary": "Fast SVG, rendered with virtual DOM diffing",
5 | "license": "BSD-3-Clause",
6 | "version": "1.0.1",
7 | "exposed-modules": {
8 | "SVG": [
9 | "Svg",
10 | "Svg.Attributes",
11 | "Svg.Events"
12 | ],
13 | "Optimize": [
14 | "Svg.Keyed",
15 | "Svg.Lazy"
16 | ]
17 | },
18 | "elm-version": "0.19.0 <= v < 0.20.0",
19 | "dependencies": {
20 | "elm/core": "1.0.0 <= v < 2.0.0",
21 | "elm/html": "1.0.0 <= v < 2.0.0",
22 | "elm/json": "1.0.0 <= v < 2.0.0",
23 | "elm/virtual-dom": "1.0.0 <= v < 2.0.0"
24 | },
25 | "test-dependencies": {}
26 | }
--------------------------------------------------------------------------------
/svg/examples/Logo.elm:
--------------------------------------------------------------------------------
1 | import Svg exposing (..)
2 | import Svg.Attributes exposing (..)
3 |
4 | main =
5 | svg
6 | [ version "1.1", x "0", y "0", viewBox "0 0 323.141 322.95"
7 | ]
8 | [ polygon [ fill "#F0AD00", points "161.649,152.782 231.514,82.916 91.783,82.916" ] []
9 | , polygon [ fill "#7FD13B", points "8.867,0 79.241,70.375 232.213,70.375 161.838,0" ] []
10 | , rect
11 | [ fill "#7FD13B", x "192.99", y "107.392", width "107.676", height "108.167"
12 | , transform "matrix(0.7071 0.7071 -0.7071 0.7071 186.4727 -127.2386)"
13 | ]
14 | []
15 | , polygon [ fill "#60B5CC", points "323.298,143.724 323.298,0 179.573,0" ] []
16 | , polygon [ fill "#5A6378", points "152.781,161.649 0,8.868 0,314.432" ] []
17 | , polygon [ fill "#F0AD00", points "255.522,246.655 323.298,314.432 323.298,178.879" ] []
18 | , polygon [ fill "#60B5CC", points "161.649,170.517 8.869,323.298 314.43,323.298" ] []
19 | ]
20 |
--------------------------------------------------------------------------------
/svg/src/Svg/Keyed.elm:
--------------------------------------------------------------------------------
1 | module Svg.Keyed exposing ( node )
2 | {-| A keyed node helps optimize cases where children are getting added, moved,
3 | removed, etc. Common examples include:
4 |
5 | - The user can delete items from a list.
6 | - The user can create new items in a list.
7 | - You can sort a list based on name or date or whatever.
8 |
9 | When you use a keyed node, every child is paired with a string identifier. This
10 | makes it possible for the underlying diffing algorithm to reuse nodes more
11 | efficiently.
12 |
13 | # Keyed Nodes
14 | @docs node
15 |
16 | -}
17 |
18 |
19 | import Svg exposing (Attribute, Svg)
20 | import VirtualDom
21 | import Json.Encode as Json
22 |
23 |
24 | {-| Works just like `Svg.node`, but you add a unique identifier to each child
25 | node. You want this when you have a list of nodes that is changing: adding
26 | nodes, removing nodes, etc. In these cases, the unique identifiers help make
27 | the DOM modifications more efficient.
28 | -}
29 | node : String -> List (Attribute msg) -> List ( String, Svg msg ) -> Svg msg
30 | node =
31 | VirtualDom.keyedNodeNS "http://www.w3.org/2000/svg"
--------------------------------------------------------------------------------
/test/.gitignore:
--------------------------------------------------------------------------------
1 | *~
2 | node_modules/
3 | elm-stuff/
4 | docs/
5 | *.html
6 | /documentation.json
7 |
--------------------------------------------------------------------------------
/test/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 |
3 | language: node_js
4 | node_js:
5 | - "8"
6 | - "10"
7 | - "12"
8 |
9 | os:
10 | - osx
11 | - linux
12 |
13 | install:
14 | - node --version
15 | - npm --version
16 | - npm install
17 |
18 | script:
19 | - npm test
20 |
--------------------------------------------------------------------------------
/test/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2016-2018 The elm-test contributors
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 |
7 | * Redistributions of source code must retain the above copyright notice, this
8 | list of conditions and the following disclaimer.
9 |
10 | * Redistributions in binary form must reproduce the above copyright notice,
11 | this list of conditions and the following disclaimer in the documentation
12 | and/or other materials provided with the distribution.
13 |
14 | * Neither the name of elm-test nor the names of its
15 | contributors may be used to endorse or promote products derived from
16 | this software without specific prior written permission.
17 |
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/test/PUBLISHING.md:
--------------------------------------------------------------------------------
1 |
2 | You will need the following:
3 |
4 | - Contributor access to `elm-explorations/test`
5 | - Able to run `runhaskell` from the command line
6 |
7 | How to publish a release:
8 |
9 | 1. Check out the `master` branch and make sure it is up-to-date.
10 | 1. Run `npx elm diff` and make sure the version change is what you expect.
11 | 1. Run `npx elm bump`.
12 | 1. Update `./tests/elm.json`, `./tests/test.sh`, and `./tests/MakeTestRegistry.hs` to use the new version number.
13 | 1. Make sure the tests run `npm install && npm test`
14 | 1. Running the tests should have modified `./tests/versions.dat` (if not, you need to install Haskell such that you have `runhaskell` on your path)
15 | 1. Commit the changes to `./elm.json`, `./tests/elm.json`, `./tests/test.sh`, `./tests/MakeTestRegistry.hs`, and `./tests/versions.dat`
16 | 1. Run `npx elm publish` -- it should fail complaining that the version is not tagged.
17 | 1. Tag and push the release using the git commands that elm publish suggested.
18 | 1. Run `npx elm publish` to publish the release.
19 |
--------------------------------------------------------------------------------
/test/benchmarks/README.md:
--------------------------------------------------------------------------------
1 | # Benchmarks for elm-test
2 |
3 | These are some benchmarks of the elm-test library built using the excellent [elm-benchmark](https://github.com/BrianHicks/elm-benchmark).
4 |
5 | ## How to run
6 |
7 | ```sh
8 | cd ./benchmarks
9 | elm-make Main.elm
10 | open index.html
11 | ```
12 |
13 | ## How to use
14 | These benchmarks can help get an idea of the performance impact of a change in the elm-test code.
15 | Beware however that a fifty percent performance increase in these benchmarks will most likely not translate to a fifty percent faster tests for users.
16 | In real word scenario's the execution of the test body will have a significant impact on the running time of the test suite, an aspect we're not testing here because it's different for every test suite.
17 | To get a feeling for the impact your change has on actual test run times try running some real test suites with and without your changes.
18 |
19 | ## Benchmarking complete test suites
20 | These are some examples of test suites that contain a lot of fuzzer tests:
21 | - [elm-benchmark](https://github.com/BrianHicks/elm-benchmark)
22 | - [elm-nonempty-list](https://github.com/mgold/elm-nonempty-list)
23 | - [json-elm-schema](https://github.com/NoRedInk/json-elm-schema)
24 |
25 | A tool you can use for benchmarking the suite is [bench](https://github.com/Gabriel439/bench).
26 |
27 | To run the tests using your modified code (this only works if your modified version is backwards compatible with the version of elm-test currenlty in use by the test suite):
28 | - In your test suite directories `elm-package.json`:
29 | - Remove the dependency on `elm-test`.
30 | - Add dependecies of `elm-test` as dependencies of the test suite itself.
31 | - Add the path to your changed elm-test src directory to your `source-directories`.
32 | It will be something like `//elm-test/src`.
33 | - Run `elm-test` once to trigger compilation.
34 | - Now run `elm-test` with your benchmarking tool.
35 |
--------------------------------------------------------------------------------
/test/benchmarks/elm-package.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "1.0.0",
3 | "summary": "helpful summary of your project, less than 80 characters",
4 | "repository": "https://github.com/user/project.git",
5 | "license": "BSD3",
6 | "source-directories": [
7 | ".",
8 | "../src"
9 | ],
10 | "exposed-modules": [],
11 | "dependencies": {
12 | "BrianHicks/elm-benchmark": "1.0.2 <= v < 2.0.0",
13 | "eeue56/elm-lazy-list": "1.0.0 <= v < 2.0.0",
14 | "eeue56/elm-shrink": "1.0.0 <= v < 2.0.0",
15 | "elm-lang/core": "5.1.1 <= v < 6.0.0",
16 | "elm-lang/html": "2.0.0 <= v < 3.0.0",
17 | "eeue56/elm-lazy": "1.0.0 <= v < 2.0.0",
18 | "mgold/elm-random-pcg": "5.0.0 <= v < 6.0.0"
19 | },
20 | "elm-version": "0.18.0 <= v < 0.19.0"
21 | }
22 |
--------------------------------------------------------------------------------
/test/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "package",
3 | "name": "elm-explorations/test",
4 | "summary": "Write unit and fuzz tests for Elm code.",
5 | "license": "BSD-3-Clause",
6 | "version": "1.2.2",
7 | "exposed-modules": [
8 | "Test",
9 | "Test.Runner",
10 | "Test.Runner.Failure",
11 | "Expect",
12 | "Fuzz",
13 | "Shrink",
14 | "Test.Html.Event",
15 | "Test.Html.Query",
16 | "Test.Html.Selector"
17 | ],
18 | "elm-version": "0.19.0 <= v < 0.20.0",
19 | "dependencies": {
20 | "elm/core": "1.0.0 <= v < 2.0.0",
21 | "elm/browser": "1.0.0 <= v < 2.0.0",
22 | "elm/html": "1.0.0 <= v < 2.0.0",
23 | "elm/json": "1.0.0 <= v < 2.0.0",
24 | "elm/random": "1.0.0 <= v < 2.0.0",
25 | "elm/virtual-dom": "1.0.0 <= v < 2.0.0"
26 | },
27 | "test-dependencies": {}
28 | }
29 |
--------------------------------------------------------------------------------
/test/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "elm-test-tests",
3 | "version": "0.0.0",
4 | "description": "tests for elm-test, so you can elm-test while you elm-test",
5 | "scripts": {
6 | "test": "elm make --docs=documentation.json && (cd tests && ./test.sh) && elm-format --validate src tests/src benchmarks"
7 | },
8 | "author": "Richard Feldman",
9 | "license": "BSD-3-Clause",
10 | "devDependencies": {
11 | "elm": "^0.19.0-bugfix2",
12 | "elm-format": "^0.8.0"
13 | },
14 | "dependencies": {}
15 | }
16 |
--------------------------------------------------------------------------------
/test/src/Elm/Kernel/Test.js:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | import Elm.Kernel.Utils exposing (Tuple0)
4 | import Result exposing (Err, Ok)
5 |
6 | */
7 |
8 |
9 | function _Test_runThunk(thunk)
10 | {
11 | try {
12 | // Attempt to run the thunk as normal.
13 | return __Result_Ok(thunk(__Utils_Tuple0));
14 | } catch (err) {
15 | // If it throws, return an error instead of crashing.
16 | return __Result_Err(err.toString());
17 | }
18 | }
19 |
20 | /* ESLINT GLOBAL VARIABLES
21 | *
22 | * Do not edit below this line as it is generated by tests/generate-globals.py
23 | */
24 |
25 | /* eslint no-unused-vars: ["error", { "varsIgnorePattern": "_Test_.*" }] */
26 |
27 | /* global __Utils_Tuple0 */
28 | /* global __Result_Err, __Result_Ok */
29 |
--------------------------------------------------------------------------------
/test/src/MicroRandomExtra.elm:
--------------------------------------------------------------------------------
1 | module MicroRandomExtra exposing (bool, frequency, lengthString, oneIn, sample)
2 |
3 | {-| Most of these are copied from elm-random-extra.
4 | -}
5 |
6 | import Array exposing (Array)
7 | import Random exposing (..)
8 | import String
9 |
10 |
11 | lengthString : Generator Char -> Int -> Generator String
12 | lengthString charGenerator stringLength =
13 | list stringLength charGenerator
14 | |> map String.fromList
15 |
16 |
17 | bool : Generator Bool
18 | bool =
19 | int 0 1 |> map ((==) 0)
20 |
21 |
22 | sample : List a -> Generator (Maybe a)
23 | sample =
24 | let
25 | find k ys =
26 | case ys of
27 | [] ->
28 | Nothing
29 |
30 | z :: zs ->
31 | if k == 0 then
32 | Just z
33 |
34 | else
35 | find (k - 1) zs
36 | in
37 | \xs -> map (\i -> find i xs) (int 0 (List.length xs - 1))
38 |
39 |
40 | oneIn : Int -> Generator Bool
41 | oneIn n =
42 | map ((==) 1) (int 1 n)
43 |
44 |
45 | frequency : ( Float, Generator a ) -> List ( Float, Generator a ) -> Generator a
46 | frequency firstPair restPairs =
47 | let
48 | total =
49 | List.sum <| List.map (abs << Tuple.first) (firstPair :: restPairs)
50 |
51 | pick ( k, g ) restChoices n =
52 | if n <= k then
53 | g
54 |
55 | else
56 | case restChoices of
57 | [] ->
58 | g
59 |
60 | next :: rest ->
61 | pick next rest (n - k)
62 | in
63 | float 0 total |> andThen (pick firstPair restPairs)
64 |
--------------------------------------------------------------------------------
/test/src/Test/Expectation.elm:
--------------------------------------------------------------------------------
1 | module Test.Expectation exposing (Expectation(..), fail, withGiven)
2 |
3 | import Test.Runner.Failure exposing (Reason)
4 |
5 |
6 | type Expectation
7 | = Pass
8 | | Fail { given : Maybe String, description : String, reason : Reason }
9 |
10 |
11 | {-| Create a failure without specifying the given.
12 | -}
13 | fail : { description : String, reason : Reason } -> Expectation
14 | fail { description, reason } =
15 | Fail { given = Nothing, description = description, reason = reason }
16 |
17 |
18 | {-| Set the given (fuzz test input) of an expectation.
19 | -}
20 | withGiven : String -> Expectation -> Expectation
21 | withGiven newGiven expectation =
22 | case expectation of
23 | Fail failure ->
24 | Fail { failure | given = Just newGiven }
25 |
26 | Pass ->
27 | expectation
28 |
--------------------------------------------------------------------------------
/test/src/Test/Html/Descendant.elm:
--------------------------------------------------------------------------------
1 | module Test.Html.Descendant exposing (isDescendant)
2 |
3 | import Html exposing (Html)
4 | import Test.Html.Internal.ElmHtml.InternalTypes exposing (ElmHtml(..))
5 | import Test.Html.Internal.Inert exposing (fromHtml, toElmHtml)
6 |
7 |
8 | isDescendant : List (ElmHtml msg) -> ElmHtml msg -> Bool
9 | isDescendant html potentialDescendant =
10 | case html of
11 | [] ->
12 | False
13 |
14 | current :: rest ->
15 | if current == potentialDescendant then
16 | True
17 |
18 | else
19 | isDescendant
20 | (prependChildren current rest)
21 | potentialDescendant
22 |
23 |
24 | prependChildren : ElmHtml msg -> List (ElmHtml msg) -> List (ElmHtml msg)
25 | prependChildren parentNode nodeList =
26 | case parentNode of
27 | NodeEntry { children } ->
28 | List.concat [ children, nodeList ]
29 |
30 | _ ->
31 | nodeList
32 |
--------------------------------------------------------------------------------
/test/src/Test/Html/Internal/ElmHtml/Constants.elm:
--------------------------------------------------------------------------------
1 | module Test.Html.Internal.ElmHtml.Constants exposing
2 | ( propKey, styleKey, eventKey, attributeKey, attributeNamespaceKey
3 | , knownKeys
4 | )
5 |
6 | {-| Constants for representing internal keys for Elm's vdom implementation
7 |
8 | @docs propKey, styleKey, eventKey, attributeKey, attributeNamespaceKey
9 | @docs knownKeys
10 |
11 | -}
12 |
13 |
14 | {-| Internal key for attribute properties
15 | -}
16 | propKey : String
17 | propKey =
18 | "a2"
19 |
20 |
21 | {-| Internal key for style
22 | -}
23 | styleKey : String
24 | styleKey =
25 | "a1"
26 |
27 |
28 | {-| Internal key for style
29 | -}
30 | eventKey : String
31 | eventKey =
32 | "a0"
33 |
34 |
35 | {-| Internal key for style
36 | -}
37 | attributeKey : String
38 | attributeKey =
39 | "a3"
40 |
41 |
42 | {-| Internal key for style
43 | -}
44 | attributeNamespaceKey : String
45 | attributeNamespaceKey =
46 | "a4"
47 |
48 |
49 | {-| Keys that we are aware of and should pay attention to
50 | -}
51 | knownKeys : List String
52 | knownKeys =
53 | [ styleKey, eventKey, attributeKey, attributeNamespaceKey ]
54 |
--------------------------------------------------------------------------------
/test/src/Test/Html/Internal/ElmHtml/Helpers.elm:
--------------------------------------------------------------------------------
1 | module Test.Html.Internal.ElmHtml.Helpers exposing (filterKnownKeys)
2 |
3 | {-| Internal helpers for ElmHtml
4 |
5 | @docs filterKnownKeys
6 |
7 | -}
8 |
9 | import Dict exposing (Dict)
10 | import Test.Html.Internal.ElmHtml.Constants exposing (knownKeys)
11 |
12 |
13 | {-| Filter out keys that we don't know
14 | -}
15 | filterKnownKeys : Dict String a -> Dict String a
16 | filterKnownKeys =
17 | Dict.filter (\key _ -> not (List.member key knownKeys))
18 |
--------------------------------------------------------------------------------
/test/src/Test/Html/Internal/ElmHtml/Markdown.elm:
--------------------------------------------------------------------------------
1 | module Test.Html.Internal.ElmHtml.Markdown exposing
2 | ( MarkdownOptions, MarkdownModel, baseMarkdownModel
3 | , decodeMarkdownModel
4 | )
5 |
6 | {-| Markdown helpers
7 |
8 | @docs MarkdownOptions, MarkdownModel, baseMarkdownModel
9 |
10 | @docs decodeMarkdownModel
11 |
12 | -}
13 |
14 | import Json.Decode exposing (field)
15 | import Json.Encode
16 | import Test.Internal.KernelConstants exposing (kernelConstants)
17 |
18 |
19 | {-| Just a default markdown model
20 | -}
21 | baseMarkdownModel : MarkdownModel
22 | baseMarkdownModel =
23 | { options =
24 | { githubFlavored = Just { tables = False, breaks = False }
25 | , defaultHighlighting = Nothing
26 | , sanitize = False
27 | , smartypants = False
28 | }
29 | , markdown = ""
30 | }
31 |
32 |
33 | {-| options markdown expects
34 | -}
35 | type alias MarkdownOptions =
36 | { githubFlavored : Maybe { tables : Bool, breaks : Bool }
37 | , defaultHighlighting : Maybe String
38 | , sanitize : Bool
39 | , smartypants : Bool
40 | }
41 |
42 |
43 | {-| An internal markdown model. Options are the things you give markdown, markdown is the string
44 | -}
45 | type alias MarkdownModel =
46 | { options : MarkdownOptions
47 | , markdown : String
48 | }
49 |
50 |
51 | {-| decode a markdown model
52 | -}
53 | decodeMarkdownModel : Json.Decode.Decoder MarkdownModel
54 | decodeMarkdownModel =
55 | field kernelConstants.markdown.markdown Json.Decode.string
56 | |> Json.Decode.map (MarkdownModel baseMarkdownModel.options)
57 |
--------------------------------------------------------------------------------
/test/src/Test/Internal/KernelConstants.elm:
--------------------------------------------------------------------------------
1 | module Test.Internal.KernelConstants exposing (kernelConstants)
2 |
3 | {-| This module defines the mapping of optimized field name and enum values
4 | for kernel code in other packages the we depend on.
5 | -}
6 |
7 |
8 | {-| NOTE: this is duplicating constants also defined in src/Elm/Kernel/HtmlAsJson.js
9 | so if you make any changes here, be sure to synchronize them there!
10 | -}
11 | kernelConstants =
12 | { virtualDom =
13 | { nodeType = "$"
14 | , nodeTypeText = 0
15 | , nodeTypeKeyedNode = 2
16 | , nodeTypeNode = 1
17 | , nodeTypeCustom = 3
18 | , nodeTypeTagger = 4
19 | , nodeTypeThunk = 5
20 | , tag = "c"
21 | , kids = "e"
22 | , facts = "d"
23 | , descendantsCount = "b"
24 | , text = "a"
25 | , refs = "l"
26 | , node = "k"
27 | , tagger = "j"
28 | , model = "g"
29 | }
30 | , markdown =
31 | { options = "a"
32 | , markdown = "b"
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/test/tests/.gitignore:
--------------------------------------------------------------------------------
1 | /elm.js
2 | /elm_home/
3 |
--------------------------------------------------------------------------------
/test/tests/README.md:
--------------------------------------------------------------------------------
1 | ## Running the tests for elm-test itself
2 |
3 | 1. `cd` into this directory
4 | 2. `npm install`
5 | 3. `npm test`
6 |
--------------------------------------------------------------------------------
/test/tests/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | "src"
5 | ],
6 | "elm-version": "0.19.0",
7 | "dependencies": {
8 | "direct": {
9 | "elm/browser": "1.0.0",
10 | "elm/core": "1.0.0",
11 | "elm/html": "1.0.0",
12 | "elm/json": "1.0.0",
13 | "elm/random": "1.0.0",
14 | "elm/svg": "1.0.0",
15 | "elm/time": "1.0.0",
16 | "elm/url": "1.0.0",
17 | "elm/virtual-dom": "1.0.0",
18 | "elm-explorations/linear-algebra": "1.0.3",
19 | "elm-explorations/markdown": "1.0.0",
20 | "elm-explorations/test": "1.2.2",
21 | "elm-explorations/webgl": "1.0.1",
22 | "jinjor/elm-diff": "1.0.5",
23 | "rtfeldman/elm-validate": "4.0.1"
24 | },
25 | "indirect": {
26 | "elm/regex": "1.0.0"
27 | }
28 | },
29 | "test-dependencies": {
30 | "direct": {},
31 | "indirect": {}
32 | }
33 | }
--------------------------------------------------------------------------------
/test/tests/src/ShrinkTests.elm:
--------------------------------------------------------------------------------
1 | module ShrinkTests exposing (all)
2 |
3 | import Expect
4 | import Shrink
5 | import Test exposing (..)
6 |
7 |
8 | all : Test
9 | all =
10 | describe "Shrink"
11 | [ describe "list" <|
12 | let
13 | shrink =
14 | Shrink.shrink (always True) (Shrink.list Shrink.unit)
15 | in
16 | [ test "empty list does not shrink" <|
17 | \() ->
18 | shrink []
19 | |> Expect.equal []
20 | , test "singleton list shrinks to empty" <|
21 | \() ->
22 | shrink [ () ]
23 | |> Expect.equal []
24 | ]
25 | ]
26 |
--------------------------------------------------------------------------------
/test/tests/src/Test/Html/ExampleApp.elm:
--------------------------------------------------------------------------------
1 | module Test.Html.ExampleApp exposing (exampleModel, view)
2 |
3 | import Html exposing (..)
4 | import Html.Attributes exposing (..)
5 | import Html.Events exposing (onClick)
6 | import Html.Keyed as Keyed
7 | import Html.Lazy as Lazy
8 |
9 |
10 | type alias Model =
11 | ()
12 |
13 |
14 | exampleModel : Model
15 | exampleModel =
16 | ()
17 |
18 |
19 | type Msg
20 | = GoToHome
21 | | GoToExamples
22 |
23 |
24 | view : Model -> Html Msg
25 | view model =
26 | div [ class "container" ]
27 | [ header [ class "funky themed", id "heading" ]
28 | [ a [ href "http://elm-lang.org", onClick GoToHome ] [ text "home" ]
29 | , a [ href "http://elm-lang.org/examples", onClick GoToExamples ] [ text "examples" ]
30 | , a [ href "http://elm-lang.org/docs" ] [ text "docs" ]
31 | ]
32 | , section [ class "funky themed", id "section" ]
33 | [ someList ]
34 | , footer [] [ text "this is the footer" ]
35 | ]
36 |
37 |
38 | someList : Html Msg
39 | someList =
40 | Keyed.ul [ class "some-list" ]
41 | [ ( "1"
42 | , Lazy.lazy (\_ -> li [ class "list-item themed" ] [ text "first item" ])
43 | Nothing
44 | )
45 | , ( "2"
46 | , Lazy.lazy (\_ -> li [ class "list-item themed" ] [ text "second item" ])
47 | Nothing
48 | )
49 | , ( "3"
50 | , Lazy.lazy (\_ -> li [ class "list-item themed selected" ] [ text "third item" ])
51 | Nothing
52 | )
53 | , ( "4"
54 | , Lazy.lazy (\_ -> li [ class "list-item themed" ] [ text "fourth item" ])
55 | Nothing
56 | )
57 | ]
58 |
--------------------------------------------------------------------------------
/test/tests/src/Test/Html/Query/CustomNodeTests.elm:
--------------------------------------------------------------------------------
1 | module Test.Html.Query.CustomNodeTests exposing (all)
2 |
3 | import Expect
4 | import Html exposing (Html, div)
5 | import Markdown
6 | import Math.Matrix4 as Mat4 exposing (Mat4)
7 | import Math.Vector3 as Vec3 exposing (Vec3, vec3)
8 | import Test exposing (..)
9 | import Test.Html.Query as Query
10 | import Test.Html.Selector exposing (..)
11 | import WebGL exposing (Mesh, Shader)
12 |
13 |
14 | all : Test
15 | all =
16 | describe "querying Html that contains other kinds of custom virtual-dom nodes"
17 | [ test "can process Html containing a WebGL node" <|
18 | \() ->
19 | div []
20 | [ webGlView
21 | , Html.text "hello with webgl"
22 | ]
23 | |> Query.fromHtml
24 | |> Query.has
25 | [ text "hello with webgl" ]
26 | ]
27 |
28 |
29 | webGlView : Html msg
30 | webGlView =
31 | WebGL.toHtml
32 | []
33 | [ WebGL.entity
34 | vertexShader
35 | fragmentShader
36 | (WebGL.triangles [])
37 | {}
38 | ]
39 |
40 |
41 | vertexShader : Shader {} {} {}
42 | vertexShader =
43 | [glsl|
44 | void main () {
45 | }
46 | |]
47 |
48 |
49 | fragmentShader : Shader {} {} {}
50 | fragmentShader =
51 | [glsl|
52 | void main () {
53 | }
54 | |]
55 |
--------------------------------------------------------------------------------
/test/tests/src/Test/Html/Query/MarkdownTests.elm:
--------------------------------------------------------------------------------
1 | module Test.Html.Query.MarkdownTests exposing (all)
2 |
3 | import Expect
4 | import Markdown
5 | import Test exposing (..)
6 | import Test.Html.Query as Query
7 | import Test.Html.Selector exposing (..)
8 |
9 |
10 | all : Test
11 | all =
12 | describe "querying Html that contains markdown nodes from elm-explorations/markdown"
13 | [ test "can process Html containing an elm-explorations/markdown node" <|
14 | \() ->
15 | Markdown.toHtml [] """
16 |
17 | # Apple Pie Recipe
18 |
19 | 1. Invent the universe.
20 | 2. Bake an apple pie.
21 |
22 | """
23 | |> Query.fromHtml
24 | |> Query.has
25 | [ text "Apple Pie Recipe" ]
26 | ]
27 |
--------------------------------------------------------------------------------
/test/tests/test.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | set -ex
4 |
5 | rm -f elm.js
6 | rm -Rf elm-stuff
7 | rm -Rf elm_home/0.19.0/package/elm-explorations/test
8 |
9 | mkdir -p elm_home
10 | mkdir -p elm_home/0.19.0/package
11 |
12 | PACKAGE_VERSION="1.2.2"
13 | mkdir -p elm_home/0.19.0/package/elm-explorations/test/${PACKAGE_VERSION}
14 | rsync -va ../ elm_home/0.19.0/package/elm-explorations/test/${PACKAGE_VERSION}/ --exclude tests --exclude elm-stuff --exclude .git --exclude node_modules
15 |
16 | if which runhaskell; then
17 | # this produces ./versions.dat, but that file
18 | # is checked in, so it's fine to skip regenerating if
19 | # haskell is not available (such as on CI)
20 | runhaskell MakeTestRegistry.hs
21 | elif which stack; then
22 | stack runhaskell MakeTestRegistry.hs
23 | else
24 | echo "$0: WARNING: Neither runhaskell or stack are available on your PATH, so I can't regenerate versions.dat"
25 | fi
26 | cp ./versions.dat elm_home/0.19.0/package/versions.dat
27 |
28 | export ELM_HOME="$(pwd)"/elm_home
29 |
30 | elm make src/Main.elm --output elm.js
31 |
32 | node elm.js
33 |
--------------------------------------------------------------------------------
/test/tests/versions.dat:
--------------------------------------------------------------------------------
1 |
eeue56 elm-lazy eeue56
elm-lazy-list eeue56
2 | elm-shrink elm browser elm core elm html elm json elm random elm time elm url elm virtual-dom elm-explorations test jinjor elm-diff
--------------------------------------------------------------------------------
/tests/.gitignore:
--------------------------------------------------------------------------------
1 | /elm-home/
2 |
--------------------------------------------------------------------------------
/tests/browser-tests/.gitignore:
--------------------------------------------------------------------------------
1 | /generated/
2 |
--------------------------------------------------------------------------------
/tests/browser-tests/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | "."
5 | ],
6 | "elm-version": "0.19.1",
7 | "dependencies": {
8 | "direct": {
9 | "elm/browser": "1.0.1",
10 | "elm/core": "1.0.5",
11 | "elm/html": "1.0.0",
12 | "elm/json": "1.1.3"
13 | },
14 | "indirect": {
15 | "elm/time": "1.0.0",
16 | "elm/url": "1.0.0",
17 | "elm/virtual-dom": "1.0.2"
18 | }
19 | },
20 | "test-dependencies": {
21 | "direct": {},
22 | "indirect": {}
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/tests/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | "src"
5 | ],
6 | "elm-version": "0.19.1",
7 | "dependencies": {
8 | "direct": {
9 | "elm/browser": "1.0.2",
10 | "elm/core": "1.0.5",
11 | "elm/html": "1.0.0"
12 | },
13 | "indirect": {
14 | "elm/json": "1.1.3",
15 | "elm/time": "1.0.0",
16 | "elm/url": "1.0.0",
17 | "elm/virtual-dom": "1.0.2"
18 | }
19 | },
20 | "test-dependencies": {
21 | "direct": {
22 | "elm/bytes": "1.0.8",
23 | "elm/random": "1.0.0",
24 | "elm-explorations/test": "1.2.2",
25 | "rtfeldman/elm-hex": "1.0.0"
26 | },
27 | "indirect": {
28 | "elm/random": "1.0.0"
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/tests/src/empty:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/another-elm/std/fb77ab931256b965ae8737d9ffb069480719b8e6/tests/src/empty
--------------------------------------------------------------------------------
/tests/sscce-tests/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | **/*.rs.bk
3 | elm-stuff/
4 | /suite/config.json
5 | /tmp/
6 | /node_modules/
7 | /.elm/
8 | /.cargo/
9 |
--------------------------------------------------------------------------------
/tests/sscce-tests/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "elm-torture"
3 | version = "0.1.0"
4 | authors = ["Harry Sarson "]
5 | edition = "2018"
6 |
7 | [dependencies]
8 | anyhow = "1.0.40"
9 | apply = "0.3"
10 | bstr = "0.2"
11 | clap = "3.0.0-beta.1"
12 | colored = "2.0"
13 | crossbeam = "0.8.0"
14 | env_logger = "0.8"
15 | futures = "0.3.13"
16 | humantime = "2.0.1"
17 | humantime-serde = "1.0.0"
18 | indented = "0.1.0"
19 | lazy_static = "1.4"
20 | log = "0.4"
21 | once_cell = "1.7"
22 | pathdiff = "0.2.0"
23 | rayon = "1.5"
24 | rust-embed = "5.6.0"
25 | same-file = "1.0.6"
26 | serde_json = "1.0"
27 | serde = { version = "1.0", features = ["derive", "rc"] }
28 | tempfile = "3.1.0"
29 | tokio = { version = "1.4.0", features = ["full"] }
30 | wait-timeout = "0.2.0"
31 | warp = { version = "0.3.1", features = ["tls"] }
32 | which = "4.1"
33 | itertools = "0.10.0"
34 | json_comments = "0.2.0"
35 |
36 |
--------------------------------------------------------------------------------
/tests/sscce-tests/README.md:
--------------------------------------------------------------------------------
1 | # SSCEE tests for the elm compiler and standard libraries
2 |
3 | [](https://github.com/harrysarson/elm-torture/actions)
4 |
--------------------------------------------------------------------------------
/tests/sscce-tests/bors.toml:
--------------------------------------------------------------------------------
1 | cut-body-after = "---"
2 | delete-merged-branches = true
3 |
4 | status = [
5 | "Torture (macos-latest)",
6 | "Torture (ubuntu-latest)",
7 | "Torture (windows-latest)",
8 | "Test (macos-latest, stable)",
9 | "Test (macos-latest, beta)",
10 | "Test (ubuntu-latest, stable)",
11 | "Test (ubuntu-latest, beta)",
12 | "Test (windows-latest, stable)",
13 | "Test (windows-latest, beta)"
14 | ]
15 |
--------------------------------------------------------------------------------
/tests/sscce-tests/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "compiler-max-retries": 20
3 | }
4 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/cert.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIIDazCCAlOgAwIBAgIUFl/dwDLLMY4XDYEMlj3IZaYlHXIwDQYJKoZIhvcNAQEL
3 | BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM
4 | GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0yMTAyMTAyMTU5MDBaFw0yNjAy
5 | MDkyMTU5MDBaMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEw
6 | HwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwggEiMA0GCSqGSIb3DQEB
7 | AQUAA4IBDwAwggEKAoIBAQC3euYRS9tzuz/QLaWumwjmvMfLxuvk3N5wpFFbIGNJ
8 | mvTEQ/jcM1rioaRp/EwJOBRs+Gj6mFWJFs2DHe5fZC8kieuXfdzflNj/Ues0Fm0O
9 | SjlO/hNpSg7Z7oUYbmskfarPe9dM1egdwDLdKd2M04xmoG7Mq2aDEvZJB8W1rFdK
10 | h+V8pFcwKtxm/qvKr1bj1J3oOM2uqjtEx6RA+XPRP/tf3uPJredEJ4J8+eLmF6Ay
11 | Ed4SCY5CQZjVNdD/wCP9+SneEqrfwDpElSdO1mGOOyXnY0odpQ8KjTG6yuJMmhQr
12 | LgLY90ZgYVVAY+nSDKqeLs9MFiNX7UYPdGK3pV0CC1r7AgMBAAGjUzBRMB0GA1Ud
13 | DgQWBBSdSBlHdhYQ76nmXwnbg9MQg2CSKjAfBgNVHSMEGDAWgBSdSBlHdhYQ76nm
14 | Xwnbg9MQg2CSKjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQAT
15 | g8MLiriZTj9nFUUDieNTRmthgOehzwWcwfL+HCJ7UifpPeO0GuDDeysDMeP9j4Rv
16 | ZGY308gvTrt8uE8Mzs7y764GYh7qfCjVNA6JFHRb49T3qTYluYIu2QvTy1sfcS9t
17 | WoSjjp8dtJq82Uk49GCiBadn0KqTduIO2OjVPpKk/ywLE8M3rNDShWsZrusVq6M5
18 | ITBWCdIUpzbh8IHbFT/VQKOVh9bAsjSfXGmVVsTyYiT3stKz3RoJZlmO8Dzh1r0j
19 | ZwXyCa/mWAuxMoBI++AmGXiJPrMDA2Oh8rRTQyk87VssVxDCsZ1ZjkailUi0jIRz
20 | DojkDWpCOEDD4fCgxdHY
21 | -----END CERTIFICATE-----
22 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/.editorconfig:
--------------------------------------------------------------------------------
1 | # -*- mode: ini-generic -*-
2 |
3 | root = true
4 |
5 | [*]
6 | indent_style = space
7 | indent_size = 2
8 | trim_trailing_whitespace = true
9 | end_of_line = lf
10 | insert_final_newline = true
11 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/.eslintignore:
--------------------------------------------------------------------------------
1 | elm-stuff
2 | node_modules
3 | .coverage
4 | .webpack
5 | src-bridge/xmlhttprequest.js
6 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/.eslintrc:
--------------------------------------------------------------------------------
1 | extends: airbnb
2 | env:
3 | mocha: true
4 | rules:
5 | arrow-parens: off
6 | comma-dangle: off
7 | func-names: off
8 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/.gitignore:
--------------------------------------------------------------------------------
1 | /tests/Doc
2 | elm-stuff
3 | node_modules
4 | *.log
5 | .coverage
6 | .serverless
7 | .webpack
8 | package-lock.json
9 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/.npmignore:
--------------------------------------------------------------------------------
1 | .coverage
2 | elm-stuff
3 | demo
4 | node_modules
5 | scripts
6 | src
7 | test
8 | tests
9 | .*
10 | circle.yml
11 | elm-package.json
12 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Release Notes
2 |
3 | ## 4.0.0 - ktonon/elm-serverless
4 |
5 | * `Conn` and `Plug` are now opaque.
6 | * `Plug` has been greatly simplified.
7 | * Simpler pipelines, just `|>` chains of `Conn -> Conn` functions. However pipelines can still send responses and terminate the connection early.
8 | * A single update function (just like an Elm SPA).
9 | * Proper JavaScript interop.
10 |
11 | ## 1.0.0 - the-sett/elm-serverless
12 |
13 | * Upgraded to Elm 0.19
14 | * Removed JavaScript interop - just use ports. Was needed as used Debug.toString to get the function names to call
15 | and this is not allowed in Elm 0.19.
16 | * Removed Logging - can't put Debug.log calls in an Elm 0.19 package. Will re-instate as a logging port in future release.
17 | * Forked as the-sett/elm-serverless.
18 | * Bridge published to npm as serverless-elm-bridge.
19 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | ## Running Tests
4 |
5 | `elm-serverless` targets Node.js 6.10. To get a development environment setup, fork and clone this repo. `npm install` will also install elm packages for the base library as well as the demo. `npm test` will perform the full range of tests including:
6 |
7 | * [./test/bridge][]: unit tests for the JavaScript package
8 | * [./test/demo][]: end-to-end tests for the included demo
9 | * [./test/Serverless][]: unit tests for the elm package
10 |
11 | The demo tests are written in JavaScript using [supertest][] and [mocha][] and rely on a running test instance of the demo server, which is started automatically when you run `npm test`. You can also launch tests in watch mode with the command `npm run test:watch`.
12 |
13 | ## Formatting
14 |
15 | This project uses [elm-format](https://github.com/avh4/elm-format/releases/tag/0.7.0-exp) release 0.7.0-exp.
16 |
17 | ```shell
18 | npm install -g elm-format@exp
19 | ```
20 |
21 | [Editor plugins](https://github.com/avh4/elm-format#editor-integration) are available to apply formatting on each save.
22 |
23 | [./test/bridge]:https://github.com/ktonon/elm-serverless/blob/master/test/bridge
24 | [./test/demo]:https://github.com/ktonon/elm-serverless/blob/master/test/demo
25 | [./test/Serverless]:https://github.com/ktonon/elm-serverless/blob/master/test/Serverless
26 | [mocha]:https://mochajs.org/
27 | [supertest]:https://github.com/visionmedia/supertest
28 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2017 Kevin Tonon
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/circle.yml:
--------------------------------------------------------------------------------
1 | machine:
2 | node:
3 | version: 6.10
4 |
5 | dependencies:
6 | cache_directories:
7 | - ~/sysconfcpus
8 | - node_modules
9 | override:
10 | - npm install
11 | - ./scripts/ci-elm-hack.sh
12 |
13 | test:
14 | post:
15 | - npm install -g coveralls
16 | - cat ./.coverage/lcov.info | coveralls
17 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/demo/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | "src",
5 | "../src"
6 | ],
7 | "elm-version": "0.19.0",
8 | "dependencies": {
9 | "direct": {
10 | "NoRedInk/elm-json-decode-pipeline": "1.0.0",
11 | "elm/core": "1.0.2",
12 | "elm/http": "2.0.0",
13 | "elm/json": "1.1.3",
14 | "elm/random": "1.0.0",
15 | "elm/url": "1.0.0"
16 | },
17 | "indirect": {
18 | "elm/bytes": "1.0.8",
19 | "elm/file": "1.0.5",
20 | "elm/time": "1.0.0"
21 | }
22 | },
23 | "test-dependencies": {
24 | "direct": {},
25 | "indirect": {}
26 | }
27 | }
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/demo/src/Config/api.js:
--------------------------------------------------------------------------------
1 | const elmServerless = require('../../../src-bridge');
2 |
3 | // Webpack has trouble with shebangs (#!)
4 | const rc = require('strip-debug-loader!shebang-loader!rc'); // eslint-disable-line
5 |
6 | const {
7 | Elm
8 | } = require('./API.elm');
9 |
10 | // Use AWS Lambda environment variables to override these values.
11 | // See the npm rc package README for more details.
12 | //
13 | // Try changing these locally by starting the server with environment variables.
14 | // For example,
15 | //
16 | // demoConfig_someService__protocol=HttPs npm start
17 | //
18 | // Also try forcing the decoder to fail to see diagnostics in the logs,
19 | //
20 | // demoConfig_someService__port=not-a-number npm start
21 | //
22 | // Of course, rc has nothing to do with elm-serverless, you can load
23 | // configuration using another tool if you prefer.
24 | //
25 | const config = rc('demoConfig', {
26 |
27 | auth: {
28 | secret: 'secret'
29 | },
30 |
31 | someService: {
32 | protocol: 'http',
33 | host: 'localhost',
34 | // Given that these are likely to be configured with environment variables,
35 | // you should only use strings here, and convert them into other values
36 | // using Elm decoders.
37 | port: '3131',
38 | },
39 |
40 | });
41 |
42 | const app = Elm.Config.API.init({
43 | flags: config
44 | });
45 |
46 | module.exports.handler = elmServerless.httpApi({
47 | app
48 | });
49 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/demo/src/Forms/api.js:
--------------------------------------------------------------------------------
1 | const elmServerless = require('../../../src-bridge');
2 |
3 | const { Elm } = require('./API.elm');
4 |
5 | module.exports.handler = elmServerless.httpApi({
6 | app: Elm.Forms.API.init(),
7 | });
8 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/demo/src/Hello/API.elm:
--------------------------------------------------------------------------------
1 | port module Hello.API exposing (main)
2 |
3 | import Serverless
4 | import Serverless.Conn exposing (respond)
5 | import Serverless.Conn.Body as Body
6 |
7 |
8 | {-| This is the "hello world" of elm-serverless.
9 |
10 | Most functionality has been disabled, by opting-out with the
11 | `Serverless.no...` constructors
12 |
13 | -}
14 | main : Serverless.Program () () () ()
15 | main =
16 | Serverless.httpApi
17 | { configDecoder = Serverless.noConfig
18 | , initialModel = ()
19 | , parseRoute = Serverless.noRoutes
20 | , update = Serverless.noSideEffects
21 | , interopPorts = Serverless.noPorts
22 |
23 | -- Entry point for new connections.
24 | , endpoint = respond ( 200, Body.text "Hello Elm on AWS Lambda" )
25 |
26 | -- Provides ports to the framework which are used for requests,
27 | -- and responses. Do not use these ports directly, the framework
28 | -- handles associating messages to specific connections with
29 | -- unique identifiers.
30 | , requestPort = requestPort
31 | , responsePort = responsePort
32 | }
33 |
34 |
35 | port requestPort : Serverless.RequestPort msg
36 |
37 |
38 | port responsePort : Serverless.ResponsePort msg
39 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/demo/src/Hello/api.js:
--------------------------------------------------------------------------------
1 | // You would normally:
2 | //
3 | // npm install -S elm-serverless
4 | //
5 | // and then require it like this:
6 | //
7 | // const elmServerless = require('elm-serverless');
8 | //
9 | // but this demo is nested in the `elm-serverless` repo, so we just
10 | // require it relative to the current module's location
11 | //
12 | const elmServerless = require('../../../src-bridge');
13 |
14 | // Import the elm app
15 | const { Elm } = require('./API.elm');
16 |
17 | // Create an AWS Lambda handler which bridges to the Elm app.
18 | module.exports.handler = elmServerless.httpApi({
19 |
20 | // Your elm app is the handler
21 | app: Elm.Hello.API.init(),
22 |
23 | // Because elm libraries cannot expose ports, you have to define them.
24 | // Whatever you call them, you have to provide the names.
25 | // The meanings are obvious. A connection comes in through the requestPort,
26 | // and the response is sent back through the responsePort.
27 | //
28 | // These are the default values, so if you follow the convention of naming
29 | // your ports in this way, you can omit these options.
30 | requestPort: 'requestPort',
31 | responsePort: 'responsePort',
32 | });
33 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/demo/src/Interop/api.js:
--------------------------------------------------------------------------------
1 | const elmServerless = require('../../../src-bridge');
2 |
3 | const {
4 | Elm
5 | } = require('./API.elm');
6 |
7 | const app = Elm.Interop.API.init();
8 |
9 | // Random numbers through a port.
10 | if (app.ports != null && app.ports.requestRand != null) {
11 | app.ports.requestRand.subscribe(args => {
12 | const connectionId = args[0];
13 | const interopSeq = args[1];
14 | app.ports.respondRand.send([connectionId, interopSeq, Math.random()]);
15 | });
16 | }
17 |
18 | // Create the serverless handler with the ports.
19 | module.exports.handler = elmServerless.httpApi({
20 | app
21 | });
22 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/demo/src/Logging.elm:
--------------------------------------------------------------------------------
1 | module Logging exposing (LogLevel(..), Logger, defaultLogger, logLevelToInt, logger, nullLogger)
2 |
3 | {-| Available Log levels
4 | -}
5 |
6 |
7 | type LogLevel
8 | = LogDebug
9 | | LogInfo
10 | | LogWarn
11 | | LogError
12 |
13 |
14 | {-| Used to order log levels
15 | -}
16 | logLevelToInt : LogLevel -> Int
17 | logLevelToInt level =
18 | case level of
19 | LogDebug ->
20 | 0
21 |
22 | LogInfo ->
23 | 1
24 |
25 | LogWarn ->
26 | 2
27 |
28 | LogError ->
29 | 3
30 |
31 |
32 | {-| A logger function
33 | -}
34 | type alias Logger a =
35 | LogLevel -> String -> a -> a
36 |
37 |
38 | {-| A logger that only logs messages at a minimum log level
39 |
40 | logger Info -- will not log Debug level messages
41 |
42 | -}
43 | logger : LogLevel -> Logger a
44 | logger minLevel level label val =
45 | if (minLevel |> logLevelToInt) > (level |> logLevelToInt) then
46 | Debug.log (Debug.toString level ++ ": " ++ label) val
47 |
48 | else
49 | val
50 |
51 |
52 | {-| Log level that is used throughout the internal library code
53 | -}
54 | defaultLogger : Logger a
55 | defaultLogger =
56 | logger LogInfo
57 |
58 |
59 | {-| Disable logging completely.
60 | -}
61 | nullLogger : Logger a
62 | nullLogger level label val =
63 | val
64 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/demo/src/Pipelines/api.js:
--------------------------------------------------------------------------------
1 | const elmServerless = require('../../../src-bridge');
2 | const rc = require('strip-debug-loader!shebang-loader!rc'); // eslint-disable-line
3 |
4 | const { Elm } = require('./API.elm');
5 |
6 | // Use AWS Lambda environment variables to override these values
7 | // See the npm rc package README for more details
8 | const config = rc('demoPipelines', {
9 | cors: {
10 | origin: '*',
11 | methods: 'get,post,options',
12 | },
13 | });
14 |
15 | module.exports.handler = elmServerless.httpApi({
16 | app: Elm.Pipelines.API.init({ flags: config }),
17 | });
18 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/demo/src/Quoted/Middleware.elm:
--------------------------------------------------------------------------------
1 | module Quoted.Middleware exposing (auth, cors)
2 |
3 | {-| Middleware is just a simple function which transforms a connection.
4 | -}
5 |
6 | import Quoted.Types exposing (Conn)
7 | import Serverless.Conn exposing (config, header, request, toSent, updateResponse)
8 | import Serverless.Conn.Body as Body
9 | import Serverless.Conn.Response exposing (addHeader, setBody, setStatus)
10 |
11 |
12 | {-| Simple function to add some cors response headers
13 | -}
14 | cors :
15 | Serverless.Conn.Conn config model route msg
16 | -> Serverless.Conn.Conn config model route msg
17 | cors conn =
18 | updateResponse
19 | (addHeader ( "access-control-allow-origin", "*" )
20 | >> addHeader ( "access-control-allow-methods", "GET,POST" )
21 | -- ...
22 | )
23 | conn
24 |
25 |
26 | {-| Dumb auth just checks if auth header is present.
27 |
28 | To demonstrate middleware which sends a response.
29 |
30 | -}
31 | auth : Conn -> Conn
32 | auth conn =
33 | case
34 | ( config conn |> .enableAuth
35 | , header "authorization" conn
36 | )
37 | of
38 | ( True, Nothing ) ->
39 | conn
40 | |> updateResponse
41 | (setStatus 401
42 | >> setBody (Body.text "Authorization header not provided")
43 | )
44 | |> toSent
45 |
46 | _ ->
47 | conn
48 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/demo/src/Quoted/Route.elm:
--------------------------------------------------------------------------------
1 | module Quoted.Route exposing (Lang(..), Query, Route(..), Sort(..), lang, query, queryEncoder, route, sort)
2 |
3 | import Json.Encode as Encode
4 | import Url.Parser exposing ((>), (>), Parser, map, oneOf, s, string, top)
5 | import Url.Parser.Query as Query
6 |
7 |
8 | type Route
9 | = Home Query
10 | | Quote Lang
11 | | Buggy
12 | | Number
13 |
14 |
15 | type Lang
16 | = LangAll
17 | | Lang String
18 |
19 |
20 | type Sort
21 | = Asc
22 | | Desc
23 |
24 |
25 | type alias Query =
26 | { q : String
27 | , sort : Sort
28 | }
29 |
30 |
31 | route : Parser (Route -> a) a
32 | route =
33 | oneOf
34 | [ map Home (top > query)
35 | , map Quote (s "quote" > lang)
36 | , map Buggy (s "buggy")
37 | , map Number (s "number")
38 | ]
39 |
40 |
41 | lang : Parser (Lang -> a) a
42 | lang =
43 | oneOf
44 | [ map LangAll top
45 | , map Lang string
46 | ]
47 |
48 |
49 | query : Parser (Query -> a) a
50 | query =
51 | map Query
52 | (top
53 | > (Query.string "q" |> Query.map (Maybe.withDefault ""))
54 | > (Query.string "sort" |> Query.map sort)
55 | )
56 |
57 |
58 | queryEncoder : Query -> Encode.Value
59 | queryEncoder qry =
60 | [ ( "q", Encode.string qry.q )
61 | , ( "sort", sortEncoder qry.sort )
62 | ]
63 | |> Encode.object
64 |
65 |
66 | sortEncoder : Sort -> Encode.Value
67 | sortEncoder srt =
68 | case srt of
69 | Asc ->
70 | Encode.string "Asc"
71 |
72 | Desc ->
73 | Encode.string "Desc"
74 |
75 |
76 | sort : Maybe String -> Sort
77 | sort =
78 | Maybe.withDefault ""
79 | >> (\val ->
80 | if val == "asc" then
81 | Asc
82 |
83 | else
84 | Desc
85 | )
86 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/demo/src/Quoted/api.js:
--------------------------------------------------------------------------------
1 | const elmServerless = require('../../../src-bridge');
2 | const rc = require('strip-debug-loader!shebang-loader!rc'); // eslint-disable-line
3 |
4 | const { Elm } = require('./API.elm');
5 |
6 | // Use AWS Lambda environment variables to override these values
7 | // See the npm rc package README for more details
8 | const config = rc('demo', {
9 | languages: ['en', 'ru'],
10 |
11 | enableAuth: 'false',
12 |
13 | cors: {
14 | origin: '*',
15 | methods: 'get,post,options',
16 | },
17 | });
18 |
19 | module.exports.handler = elmServerless.httpApi({
20 | app: Elm.Quoted.API.init({ flags: config }),
21 | requestPort: 'requestPort',
22 | responsePort: 'responsePort',
23 | });
24 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/demo/src/Routing/api.js:
--------------------------------------------------------------------------------
1 | const elmServerless = require('../../../src-bridge');
2 |
3 | const { Elm } = require('./API.elm');
4 |
5 | module.exports.handler = elmServerless.httpApi({
6 | app: Elm.Routing.API.init()
7 | });
8 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/demo/src/SideEffects/api.js:
--------------------------------------------------------------------------------
1 | const elmServerless = require('../../../src-bridge');
2 |
3 | const { Elm } = require('./API.elm');
4 |
5 | module.exports.handler = elmServerless.httpApi({
6 | app: Elm.SideEffects.API.init()
7 | });
8 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/demo/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const webpack = require('webpack');
3 | const slsw = require('serverless-webpack');
4 |
5 | const config = {
6 | entry: slsw.lib.entries,
7 | target: 'node', // Ignores built-in modules like path, fs, etc.
8 |
9 | output: {
10 | libraryTarget: 'commonjs',
11 | path: path.resolve(`${__dirname}/.webpack`),
12 | filename: '[name].js',
13 | },
14 |
15 | module: {
16 | loaders: [{
17 | // Compiles elm to JavaScript.
18 | test: /\.elm$/,
19 | exclude: [/elm-stuff/, /node_modules/],
20 | loader: 'elm-webpack-loader',
21 | options: {
22 | forceWatch: true
23 | }
24 | }],
25 | },
26 | };
27 |
28 | if (process.env.NODE_ENV === 'production') {
29 | // Bridge is written for node 6.10. While AWS Lambda supports it
30 | // the UglifyJsPlugin does not :( so until that happens we use babel.
31 | config.module.loaders.push({
32 | test: /\.js$/,
33 | exclude: [/elm-stuff/, /node_modules/],
34 | loader: 'babel-loader',
35 | options: { presets: 'env' },
36 | });
37 |
38 | config.plugins = config.plugins || [];
39 | config.plugins.push(new webpack.optimize.UglifyJsPlugin());
40 | }
41 |
42 | module.exports = config;
43 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "package",
3 | "name": "the-sett/elm-serverless",
4 | "summary": "Use Elm with the serverless framework (deploy to AWS, Azure, Google)",
5 | "license": "MIT",
6 | "version": "4.0.0",
7 | "exposed-modules": [
8 | "Serverless",
9 | "Serverless.Conn",
10 | "Serverless.Conn.Body",
11 | "Serverless.Conn.Request",
12 | "Serverless.Conn.Response",
13 | "Serverless.Plug",
14 | "Serverless.Cors"
15 | ],
16 | "elm-version": "0.19.0 <= v < 0.20.0",
17 | "dependencies": {
18 | "NoRedInk/elm-json-decode-pipeline": "1.0.0 <= v < 2.0.0",
19 | "elm/core": "1.0.2 <= v < 2.0.0",
20 | "elm/json": "1.1.3 <= v < 2.0.0",
21 | "elm/random": "1.0.0 <= v < 2.0.0",
22 | "elm/url": "1.0.0 <= v < 2.0.0"
23 | },
24 | "test-dependencies": {
25 | "elm/regex": "1.0.0 <= v < 2.0.0",
26 | "elm-explorations/test": "1.2.2 <= v < 2.0.0",
27 | "ktonon/elm-test-extra": "2.0.1 <= v < 3.0.0"
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/es-logo-small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/another-elm/std/fb77ab931256b965ae8737d9ffb069480719b8e6/tests/sscce-tests/embed-assets/elm-serverless/es-logo-small.png
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/es-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/another-elm/std/fb77ab931256b965ae8737d9ffb069480719b8e6/tests/sscce-tests/embed-assets/elm-serverless/es-logo.png
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/scripts/ci-elm-hack.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -e
4 |
5 | SYSCONFCPUS="$HOME/sysconfcpus"
6 | ELM_MAKE="$HOME/$CIRCLE_PROJECT_REPONAME/node_modules/.bin/elm-make"
7 |
8 | # Check if we have already patched it
9 | if [ -f "${ELM_MAKE}-old" ];
10 | then
11 | echo "Skipping ci-elm-hack"
12 | exit 0
13 | fi
14 |
15 | # Workaround for extremely slow elm compilation
16 | # see https://github.com/elm-lang/elm-compiler/issues/1473#issuecomment-245704142
17 | if [ ! -d "$SYSCONFCPUS/bin" ];
18 | then
19 | git clone https://github.com/obmarg/libsysconfcpus.git "$SYSCONFCPUS"
20 | pushd "$SYSCONFCPUS"
21 | ./configure --prefix="$SYSCONFCPUS"
22 | make && make install
23 | popd
24 | fi
25 |
26 | mv "$ELM_MAKE" "$ELM_MAKE-old"
27 | printf '%s\n\n' \
28 | '#!/bin/bash' \
29 | 'echo "Running elm-make with sysconfcpus -n 2"' \
30 | "$SYSCONFCPUS"'/bin/sysconfcpus -n 2 '"$ELM_MAKE"'-old "$@"' \
31 | > "$ELM_MAKE"
32 | chmod +x "$ELM_MAKE"
33 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/scripts/stop-test-server.js:
--------------------------------------------------------------------------------
1 | const psList = require('ps-list'); // eslint-disable-line import/no-extraneous-dependencies
2 | const { port } = require('../test/demo/request');
3 |
4 | const args = `offline --port=${port}`.split(' ');
5 | const logger = console;
6 |
7 | const findServer = () => psList().then(data => {
8 | const argsPattern = new RegExp(args.join(' '));
9 | return data.filter(({ name, cmd }) =>
10 | name === 'node' &&
11 | argsPattern.test(cmd))[0];
12 | });
13 |
14 | findServer().then(server => {
15 | if (server) {
16 | logger.info(`Stopping old test server (${server.pid})`);
17 | process.kill(server.pid);
18 | }
19 | }).catch(err => {
20 | logger.error(err);
21 | process.exit(1);
22 | });
23 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/src-bridge/index.js:
--------------------------------------------------------------------------------
1 | const xmlhttprequest = require('./xmlhttprequest');
2 |
3 | const defaultLogger = require('./logger');
4 | const Pool = require('./pool');
5 | const requestHandler = require('./request-handler');
6 | const responseHandler = require('./response-handler');
7 | const validate = require('./validate');
8 |
9 | global.XMLHttpRequest = xmlhttprequest.XMLHttpRequest;
10 |
11 | const invalidElmApp = msg => {
12 | throw new Error(`handler.init did not return valid Elm app.${msg}`);
13 | };
14 |
15 | const httpApi = ({
16 | app,
17 | logger = defaultLogger,
18 | requestPort = 'requestPort',
19 | responsePort = 'responsePort',
20 | } = {}) => {
21 | if (typeof app !== 'object') {
22 | invalidElmApp(`Got: ${validate.inspect(app)}`);
23 | }
24 | const portNames = `[${Object.keys(app.ports).sort().join(', ')}]`;
25 |
26 | validate(app.ports[responsePort], 'subscribe', {
27 | missing: `No response port named ${responsePort} among: ${portNames}`,
28 | invalid: 'Invalid response port',
29 | });
30 |
31 | validate(app.ports[requestPort], 'send', {
32 | missing: `No request port named ${requestPort} among: ${portNames}`,
33 | invalid: 'Invalid request port',
34 | });
35 |
36 | const pool = new Pool({ logger });
37 | const handleResponse = responseHandler({ pool, logger });
38 |
39 | app.ports[responsePort].subscribe(([id, jsonValue]) => {
40 | handleResponse(id, jsonValue);
41 | });
42 |
43 | return requestHandler({ pool, requestPort: app.ports[requestPort] });
44 | };
45 |
46 | module.exports = { httpApi };
47 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/src-bridge/logger.js:
--------------------------------------------------------------------------------
1 | module.exports = console;
2 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/src-bridge/normalize-headers.js:
--------------------------------------------------------------------------------
1 | const norm = oldHeaders => {
2 | const headers = {};
3 | Object.keys(oldHeaders).forEach(key => {
4 | const val = oldHeaders[key];
5 | if (val !== undefined && val !== null) {
6 | headers[key.toLowerCase()] = `${val}`;
7 | }
8 | });
9 | return headers;
10 | };
11 |
12 | module.exports = norm;
13 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/src-bridge/pool.js:
--------------------------------------------------------------------------------
1 | const defaultLogger = require('./logger');
2 |
3 | class Pool {
4 | constructor({ logger = defaultLogger } = {}) {
5 | this.connections = {};
6 | this.logger = logger;
7 | }
8 |
9 | take(id) {
10 | const conn = this.connections[id];
11 | if (conn === undefined) {
12 | this.logger.error(`No callback for ID: ${id}`);
13 | } else {
14 | delete this.connections[id];
15 | }
16 | return conn || {};
17 | }
18 |
19 | put(id, req, callback) {
20 | if (this.connections[id] !== undefined) {
21 | this.logger.error(`Duplicate connection ID: ${id}`);
22 | }
23 | if (typeof callback !== 'function') {
24 | throw new Error(`Callback is not a function: ${callback}`);
25 | }
26 | this.connections[id] = { req, callback, id };
27 | }
28 | }
29 |
30 | module.exports = Pool;
31 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/src-bridge/request-handler.js:
--------------------------------------------------------------------------------
1 | const urlencode = require('urlencode');
2 | const uuid = require('uuid');
3 |
4 | const defaultLogger = require('./logger');
5 | const norm = require('./normalize-headers');
6 |
7 | const encodeBody = body => (typeof body === 'string'
8 | ? body
9 | : JSON.stringify(body));
10 |
11 | const path = params =>
12 | `/${params[0] || params.proxy || ''}`
13 | .replace(/%2f/gi, '/');
14 |
15 | const splitHostPort = host => {
16 | const parts = typeof host === 'string' ? host.split(':') : [];
17 | return { host: parts[0], port: parts[1] };
18 | };
19 |
20 | module.exports = ({
21 | pool,
22 | requestPort,
23 | logger = defaultLogger
24 | }) => function requestHandler({
25 | body,
26 | headers = {},
27 | httpMethod,
28 | id = uuid.v4(),
29 | method = httpMethod,
30 | pathParameters,
31 | queryStringParameters = {},
32 | requestContext = {},
33 | }, context, callback) {
34 | const { host, port } = splitHostPort(headers.Host || headers.host);
35 | const { sourceIp } = requestContext.identity || {};
36 | const req = {
37 | body: encodeBody(body),
38 | headers: norm(headers),
39 | host,
40 | method,
41 | path: path(pathParameters || {}),
42 | port: parseInt(headers['X-Forwarded-Port'] || port || 80, 10), // Assume port 80, if none given.
43 | queryParams: queryStringParameters,
44 | queryString: `?${urlencode.stringify(queryStringParameters)}`,
45 | remoteIp: sourceIp || '127.0.0.1',
46 | scheme: headers['X-Forwarded-Proto'] || 'http',
47 | stage: requestContext.stage || 'local',
48 | };
49 |
50 | pool.put(id, req, callback);
51 | logger.info(JSON.stringify({ req }, null, 2));
52 | requestPort.send([id, req]);
53 | };
54 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/src-bridge/response-handler.js:
--------------------------------------------------------------------------------
1 | const defaultLogger = require('./logger');
2 |
3 | const missingStatusCodeBody = 'Application did not return a valid status code';
4 |
5 | const defaultHeaders = (body) => (typeof body === 'object'
6 | ? { 'content-type': 'application/json; charset=utf-8' }
7 | : { 'content-type': 'text/text; charset=utf-8' });
8 |
9 | const encodeBody = (body) => {
10 | switch (typeof body) {
11 | case 'string':
12 | case 'undefined':
13 | return body;
14 | case 'object':
15 | return JSON.stringify(body);
16 | default:
17 | return `${body}`;
18 | }
19 | };
20 |
21 | const handler = ({ pool, logger = defaultLogger }) => function responseHandler(id, resp) {
22 | logger.info(JSON.stringify({ resp }, null, 2));
23 | const { callback } = pool.take(id);
24 | const statusCode = parseInt(resp.statusCode, 10);
25 | if (callback) {
26 | if (isNaN(statusCode)) {
27 | callback(null, {
28 | statusCode: 500,
29 | body: `${missingStatusCodeBody}: ${resp.statusCode}`,
30 | headers: defaultHeaders(''),
31 | isBase64Encoded: !!resp.isBase64Encoded
32 | });
33 | } else {
34 | callback(null, {
35 | statusCode,
36 | body: encodeBody(resp.body, statusCode),
37 | headers: resp.headers || defaultHeaders(resp.body),
38 | isBase64Encoded: !!resp.isBase64Encoded
39 | });
40 | }
41 | } else {
42 | logger.error('resp missing callback:', id);
43 | }
44 | };
45 |
46 | module.exports = Object.assign(handler, {
47 | defaultHeaders,
48 | missingStatusCodeBody,
49 | });
50 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/src-bridge/validate.js:
--------------------------------------------------------------------------------
1 | const util = require('util');
2 |
3 | const hasFunction = (obj, attr) => (
4 | (typeof obj === 'object') &&
5 | (typeof obj[attr] === 'function'));
6 |
7 | const inspect = (val) => util.inspect(val, { depth: 2 });
8 |
9 | const validate = (obj, attr, { missing, invalid }) => {
10 | if (!hasFunction(obj, attr)) {
11 | throw new Error(obj === undefined
12 | ? missing
13 | : `${invalid}: ${inspect(obj)}`);
14 | }
15 | };
16 |
17 | module.exports = validate;
18 | module.exports.inspect = inspect;
19 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/src/Serverless/Conn/Charset.elm:
--------------------------------------------------------------------------------
1 | module Serverless.Conn.Charset exposing
2 | ( Charset
3 | , default, utf8
4 | , toString
5 | )
6 |
7 | {-| A character encoding.
8 |
9 | @docs Charset
10 |
11 | @docs default, utf8
12 |
13 | @docs toString
14 |
15 | -}
16 |
17 |
18 | {-| -}
19 | type Charset
20 | = Utf8
21 |
22 |
23 |
24 | -- CONSTRUCTORS
25 |
26 |
27 | {-| -}
28 | default : Charset
29 | default =
30 | Utf8
31 |
32 |
33 | {-| -}
34 | utf8 : Charset
35 | utf8 =
36 | Utf8
37 |
38 |
39 |
40 | -- QUERY
41 |
42 |
43 | {-| -}
44 | toString : Charset -> String
45 | toString charset =
46 | case charset of
47 | Utf8 ->
48 | "utf-8"
49 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/src/Serverless/Conn/KeyValueList.elm:
--------------------------------------------------------------------------------
1 | module Serverless.Conn.KeyValueList exposing (decoder, encode)
2 |
3 | import Json.Decode as Decode exposing (Decoder, andThen, map)
4 | import Json.Encode as Encode
5 |
6 |
7 | decoder : Decoder (List ( String, String ))
8 | decoder =
9 | Decode.keyValuePairs Decode.string
10 | |> Decode.nullable
11 | |> andThen
12 | (\maybeParams ->
13 | case maybeParams of
14 | Just params ->
15 | Decode.succeed params
16 |
17 | Nothing ->
18 | Decode.succeed []
19 | )
20 |
21 |
22 | encode : List ( String, String ) -> Encode.Value
23 | encode params =
24 | params
25 | |> List.reverse
26 | |> List.map (\( a, b ) -> ( a, Encode.string b ))
27 | |> Encode.object
28 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/src/Serverless/Conn/Pool.elm:
--------------------------------------------------------------------------------
1 | module Serverless.Conn.Pool exposing
2 | ( Pool
3 | , empty
4 | , get
5 | , remove
6 | , replace
7 | , size
8 | )
9 |
10 | import Dict exposing (Dict)
11 | import Serverless.Conn as Conn exposing (Conn, Id)
12 |
13 |
14 | type Pool config model route msg
15 | = Pool
16 | { connDict : Dict Id (Conn config model route msg)
17 | }
18 |
19 |
20 | empty : Pool config model route msg
21 | empty =
22 | Pool { connDict = Dict.empty }
23 |
24 |
25 | get :
26 | Id
27 | -> Pool config model route msg
28 | -> Maybe (Conn config model route msg)
29 | get requestId (Pool { connDict }) =
30 | Dict.get requestId connDict
31 |
32 |
33 | replace :
34 | Conn config model route msg
35 | -> Pool config model route msg
36 | -> Pool config model route msg
37 | replace conn (Pool pool) =
38 | Pool
39 | { pool
40 | | connDict =
41 | Dict.insert
42 | (Conn.id conn)
43 | conn
44 | pool.connDict
45 | }
46 |
47 |
48 | remove :
49 | Conn config model route msg
50 | -> Pool config model route msg
51 | -> Pool config model route msg
52 | remove conn (Pool pool) =
53 | Pool
54 | { pool
55 | | connDict =
56 | pool.connDict
57 | |> Dict.remove (Conn.id conn)
58 | }
59 |
60 |
61 | size : Pool config model route msg -> Int
62 | size (Pool { connDict }) =
63 | Dict.size connDict
64 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/test/bridge/normalize-headers-spec.js:
--------------------------------------------------------------------------------
1 | const norm = require('../../src-bridge/normalize-headers');
2 |
3 | describe('norm', () => {
4 | it('is a function', () => {
5 | norm.should.be.a.Function();
6 | });
7 |
8 | it('converts header keys to lowercase', () => {
9 | norm({ 'Foo-Bar': 'Some Text', Age: '3' })
10 | .should.deepEqual({
11 | 'foo-bar': 'Some Text',
12 | age: '3',
13 | });
14 | });
15 |
16 | it('converts numbers and bools to strings', () => {
17 | norm({ age: 3, good: true, bad: false })
18 | .should.deepEqual({
19 | age: '3',
20 | good: 'true',
21 | bad: 'false',
22 | });
23 | });
24 |
25 | it('removes keys with undefined or null values', () => {
26 | norm({ 'is-undef': undefined, 'is-null': null })
27 | .should.deepEqual({});
28 | });
29 | });
30 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/test/bridge/spy-logger.js:
--------------------------------------------------------------------------------
1 | const sinon = require('sinon');
2 |
3 | const spyLogger = () => ({
4 | info: sinon.spy(),
5 | warn: sinon.spy(),
6 | error: sinon.spy(),
7 | trace: sinon.spy(),
8 | });
9 |
10 | module.exports = spyLogger;
11 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/test/bridge/validate-spec.js:
--------------------------------------------------------------------------------
1 | const validate = require('../../src-bridge/validate');
2 |
3 | const missing = 'is missing';
4 | const invalid = 'is invalid';
5 | const msg = { missing, invalid };
6 |
7 | describe('validate(obj, attr, { missing, invalid })', () => {
8 | it('does nothing of the validation passes', () => {
9 | (() => validate({ foo: () => null }, 'foo', msg))
10 | .should.not.throw();
11 | });
12 |
13 | it('throws if obj has not attribute named attr', () => {
14 | (() => validate({}, 'foo', msg))
15 | .should.throw('is invalid: {}');
16 | });
17 |
18 | it('throws if obj.attr is not a function', () => {
19 | (() => validate({ foo: 'bar' }, 'foo', msg))
20 | .should.throw("is invalid: { foo: 'bar' }");
21 | });
22 |
23 | it('throws if obj is undefined', () => {
24 | (() => validate(undefined, 'foo', msg))
25 | .should.throw('is missing');
26 | });
27 | });
28 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/test/demo/config-spec.js:
--------------------------------------------------------------------------------
1 | const request = require('./request');
2 |
3 | const path = (relative) => `/config${relative}`;
4 |
5 | describe('Demo: /config', () => {
6 | it('has status 200', () =>
7 | request.get(path('/')).expect(200)
8 | );
9 |
10 | it('responds with the parsed config', () =>
11 | request.get(path('/'))
12 | .then(res => {
13 | res.text.should.equal('Config: {"auth":{"secret":"secret"},"someService":{"protocol":"http","host":"localhost","port":3131}}');
14 | })
15 | );
16 | });
17 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/test/demo/hello-spec.js:
--------------------------------------------------------------------------------
1 | const request = require('./request');
2 |
3 | const greeting = 'Hello Elm on AWS Lambda';
4 | const path = (relative) => `${relative}`;
5 |
6 | describe('Demo: /', () => {
7 | describe('GET /', () => {
8 | it('has status 200', () =>
9 | request.get(path('/')).expect(200)
10 | );
11 |
12 | it('responds with plain text', () =>
13 | request.get(path('/'))
14 | .then(res => {
15 | res.headers.should.have.property('content-type')
16 | .which.equal('text/text; charset=utf-8');
17 | res.text.should.equal(greeting);
18 | })
19 | );
20 | });
21 | });
22 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/test/demo/interop-spec.js:
--------------------------------------------------------------------------------
1 | const co = require('co');
2 | const should = require('should');
3 |
4 | const request = require('./request');
5 |
6 | const path = (relative) => `/interop/${relative}`;
7 |
8 | describe('Demo: /interop', () => {
9 | describe('GET /unit', () => {
10 | it('gets a random float between 0 and 1', () => co(function* () {
11 | const n = 20;
12 | const responses = yield [...Array(n)].map(() =>
13 | request.get(path('unit')).expect(200));
14 | responses.forEach(({ body }) => {
15 | should(typeof body).equal('number');
16 | body.toString().should.match(/^[01]\.\d+$/);
17 | body.should.be.aboveOrEqual(0);
18 | body.should.be.belowOrEqual(1);
19 | });
20 | should(new Set(responses.map(r => r.body)).size).above(1);
21 | }));
22 | });
23 | });
24 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/test/demo/pipelines-spec.js:
--------------------------------------------------------------------------------
1 | const should = require('should');
2 |
3 | const request = require('./request');
4 |
5 | const path = (relative) => `/pipelines${relative}`;
6 |
7 | describe('Demo: /pipelines', () => {
8 | it('has status 401', () =>
9 | request.get(path('/')).expect(401)
10 | );
11 |
12 | it('terminates the pipeline early if Unauthorized', () =>
13 | request.get(path('/')).expect(401).then(res => {
14 | should(res.headers).have.property('x-from-first-plug').equal('foo');
15 | should(res.headers).not.have.property('x-from-last-plug');
16 | res.text.should.startWith('Unauthorized');
17 | })
18 | );
19 |
20 | it('includes response headers from cors middleware', () =>
21 | request.get(path('/')).expect(401).then(res => {
22 | should(res.headers).have.property('access-control-allow-origin', '*');
23 | should(res.headers).have.property('access-control-allow-methods', 'GET,POST,OPTIONS');
24 | })
25 | );
26 |
27 | it('reflects origin from the request', () =>
28 | request
29 | .get(path('/'))
30 | .set('origin', 'foo.bar.com')
31 | .expect(401)
32 | .then(res => {
33 | should(res.headers).have.property('access-control-allow-origin', 'foo.bar.com');
34 | })
35 | );
36 |
37 | it('completes the pipeline if Authorized', () =>
38 | request
39 | .get(path('/'))
40 | .set('Authorization', 'anything')
41 | .expect(200)
42 | .then(res => {
43 | should(res.headers).have.property('x-from-first-plug').equal('foo');
44 | should(res.headers).have.property('x-from-last-plug').equal('bar');
45 | res.text.should.equal('Pipeline applied');
46 | })
47 | );
48 | });
49 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/test/demo/request.js:
--------------------------------------------------------------------------------
1 | const defaults = require('superagent-defaults');
2 | const supertest = require('supertest');
3 |
4 | const port = 3001;
5 | const endpoint = `http://localhost:${port}`;
6 |
7 | module.exports = defaults(supertest(endpoint));
8 | module.exports.port = port;
9 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/test/demo/routing-spec.js:
--------------------------------------------------------------------------------
1 | const request = require('./request');
2 |
3 | const path = (relative) => `/routing${relative}`;
4 |
5 | describe('Demo: /routing', () => {
6 | it('GET / routes to the home page', () =>
7 | request.get(path('/')).expect(200).then(res => {
8 | res.text.should.equal('The home page');
9 | })
10 | );
11 |
12 | it('GET /blog routes to the blog list', () =>
13 | request.get(path('/blog')).expect(200).then(res => {
14 | res.text.should.equal('List of recent posts...');
15 | })
16 | );
17 |
18 | it('GET /blog/some-slug routes to a specific post', () =>
19 | request.get(path('/blog/some-slug')).expect(200).then(res => {
20 | res.text.should.equal('Specific post: some-slug');
21 | })
22 | );
23 |
24 | it('POST /blog returns 405', () =>
25 | request.post(path('/blog')).expect(405)
26 | );
27 |
28 | it('GET /some/undefined/path returns 404', () =>
29 | request.post(path('/some/undefined/path')).expect(404)
30 | );
31 | });
32 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/test/mocha.opts:
--------------------------------------------------------------------------------
1 | --require should
2 | --recursive
3 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/tests/Serverless/Conn/EncodeTests.elm:
--------------------------------------------------------------------------------
1 | module Serverless.Conn.EncodeTests exposing (all)
2 |
3 | import Expect
4 | import Expect.Extra as Expect exposing (stringPattern)
5 | import Json.Encode as Encode
6 | import Serverless.Conn as Conn exposing (updateResponse)
7 | import Serverless.Conn.Body as Body
8 | import Serverless.Conn.Response as Response exposing (addHeader)
9 | import Serverless.Conn.Test as Test
10 | import Test exposing (describe, test)
11 |
12 |
13 | all : Test.Test
14 | all =
15 | describe "Serverless.Conn.Encode"
16 | [ describe "encodeBody"
17 | [ test "encodes NoBody as null" <|
18 | \_ ->
19 | Expect.equal Encode.null (Body.encode Body.empty)
20 | , test "encodes TextBody to plain text" <|
21 | \_ ->
22 | Expect.equal
23 | (Encode.string "abc123")
24 | (Body.text "abc123" |> Body.encode)
25 | ]
26 | , describe "encodeResponse"
27 | [ Test.conn "contains the most recent header (when a header is set more than once)" <|
28 | updateResponse
29 | (addHeader ( "content-type", "text/text" )
30 | >> addHeader ( "content-type", "application/xml" )
31 | )
32 | >> Conn.jsonEncodedResponse
33 | >> Encode.encode 0
34 | >> Expect.match
35 | (stringPattern "\"content-type\":\"application/xml\"")
36 | ]
37 | ]
38 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/tests/Serverless/Conn/Test.elm:
--------------------------------------------------------------------------------
1 | module Serverless.Conn.Test exposing (conn, connWith, request)
2 |
3 | import Expect exposing (Expectation)
4 | import Fuzz exposing (Fuzzer)
5 | import Serverless.Conn.Fuzz as Fuzz
6 | import Serverless.Conn.Request exposing (Request)
7 | import Test exposing (Test)
8 | import TestHelpers exposing (Conn)
9 |
10 |
11 | conn : String -> (Conn -> Expectation) -> Test
12 | conn label =
13 | Test.fuzz Fuzz.conn label
14 |
15 |
16 | connWith : Fuzzer a -> String -> (( Conn, a ) -> Expectation) -> Test
17 | connWith otherFuzzer label =
18 | Test.fuzz (Fuzz.tuple ( Fuzz.conn, otherFuzzer )) label
19 |
20 |
21 | request : String -> (Request -> Expectation) -> Test
22 | request label =
23 | Test.fuzz Fuzz.request label
24 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/tests/elm-doc-test.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": "../src",
3 | "tests": [
4 | "Serverless.Conn",
5 | "Serverless.Conn.Body",
6 | "Serverless.Conn.IpAddress",
7 | "Serverless.Plug"
8 | ]
9 | }
10 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/tests/elm-verify-examples.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": "../src",
3 | "tests": []
4 | }
5 |
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/elm-serverless/tests/elm.json.elmupgrade:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../src"
6 | ],
7 | "elm-version": "0.19.0",
8 | "dependencies": {
9 | "direct": {
10 | "NoRedInk/elm-json-decode-pipeline": "1.0.0",
11 | "elm/core": "1.0.2",
12 | "elm/html": "1.0.0",
13 | "elm/json": "1.1.3",
14 | "elm/random": "1.0.0",
15 | "elm/regex": "1.0.0",
16 | "elm-community/json-extra": "4.0.0",
17 | "elm-explorations/test": "1.2.1",
18 | "ktonon/elm-test-extra": "2.0.1",
19 | "danielnarey/elm-toolkit": "4.5.0",
20 | "elm-community/lazy-list": "1.0.0",
21 | "elm-community/shrink": "2.0.0",
22 | "ktonon/url-parser": "1.0.0"
23 | },
24 | "indirect": {
25 | "elm/parser": "1.1.0",
26 | "elm/time": "1.0.0",
27 | "elm/virtual-dom": "1.0.2",
28 | "rtfeldman/elm-iso8601-date-strings": "1.1.3"
29 | }
30 | },
31 | "test-dependencies": {
32 | "direct": {},
33 | "indirect": {}
34 | }
35 | }
--------------------------------------------------------------------------------
/tests/sscce-tests/embed-assets/key.key:
--------------------------------------------------------------------------------
1 | -----BEGIN RSA PRIVATE KEY-----
2 | MIIEowIBAAKCAQEAt3rmEUvbc7s/0C2lrpsI5rzHy8br5NzecKRRWyBjSZr0xEP4
3 | 3DNa4qGkafxMCTgUbPho+phViRbNgx3uX2QvJInrl33c35TY/1HrNBZtDko5Tv4T
4 | aUoO2e6FGG5rJH2qz3vXTNXoHcAy3SndjNOMZqBuzKtmgxL2SQfFtaxXSoflfKRX
5 | MCrcZv6ryq9W49Sd6DjNrqo7RMekQPlz0T/7X97jya3nRCeCfPni5hegMhHeEgmO
6 | QkGY1TXQ/8Aj/fkp3hKq38A6RJUnTtZhjjsl52NKHaUPCo0xusriTJoUKy4C2PdG
7 | YGFVQGPp0gyqni7PTBYjV+1GD3Rit6VdAgta+wIDAQABAoIBAGJKMB1r6a/hy5mW
8 | Gn+jBe21i8KaWZxMxczJ+ds7SnUP0beiQhqUWEe4F/++7Gyz4h1OJc649HlwAcAP
9 | tLbdUHPefpq1DjGn52c/VyScLufM006BxZxN1A7jO+GOpU7zEyH7UacToDjv0U+x
10 | McJTQY9ounJiD5R///e3di6QmGKP6hZXX1inCU4HHMioORLld1lwOI7YKl2sDg8T
11 | /dRiVlzpMgm1V8HC/ibKlIhNqDutCErE7YmdIzqc+IjV+dz5PXneiyFNrHbkDVw8
12 | 1oUH/3cEZYoaYE9zsA/ifIbRN6hdAIqIiCIddLbxzkhL5CGPMhI1TECA/rvKoYjN
13 | BELAm4ECgYEA3gf4JPXwoMVGuSlc2Xw0X43Z7UxokkHhnUa5y/J3oc89aGcbnJUH
14 | 6//L8SiP3cVq3lNzhFLVLTMRt+KQuN1H3kHyabMNtemmlR1Fca/X4xQbCc6XWI/i
15 | inI2/APXBnBvrSFD7QV2p9qCTXlqVC5evFWgccbx1Nzls5lDhQDgujECgYEA040L
16 | tM793zF698tfuBhyo5IrpPonV7WHlgT/ErTtMnUSMQROyc0O2Lbs0aoluYxCopYI
17 | 7QqPAavDw+dTCoEvGsLrC+MpPlmWImxK8eWS27KOxfatgIGyJyfGeO1W4kJHRJmQ
18 | J25NH/4lAc2qgFbhOh+8YHfynC8ihcsBAEk7cOsCgYBfqBlNezP3X+bPYTWicXNy
19 | 838/UBsBYCbehpkHd+f4q3tuXnWz6TUnhOYNeQc6aZJYRKXRDYrQVV891Pu62YLc
20 | C5dv2HeAtzBQr/K6PyMIryHTANGNkzfro7dyrgjWulwyv9Eu7ZqoSGi5DiU0LWId
21 | S9q7ChYoOh8wWEiRpcYsEQKBgQDCAcnIiUOdGj2RXftsU09e3sATzi2ibCHp3K8n
22 | srEM4vxJ44911g5VhHxuU0HBhfXeMQYCjPpVJ/aihFRNf+d4/WSdRDggq/vZmcKp
23 | UEZ8IKZ6uhyni0mcSwfjApX5bZr6OHJRFwC35FR/8OL6S7LFoTEaryXZQgjA9kj2
24 | wDI4/QKBgD3ADQci12t1dSCK+rXxro/lPdIu88JF7w/T1pSAD5T0L3svqR0TEXNI
25 | cF2WlcGHjz040uE8p8zOacnMNSnZCLP6tM/VceVHyS72eNxJhyGYIfrKse4iPWls
26 | g2qGwavC4XGHJaFxkpcrJHV7TKV8KdCAs8ud0C5zG5+RTbcpSZQU
27 | -----END RSA PRIVATE KEY-----
28 |
--------------------------------------------------------------------------------
/tests/sscce-tests/exit-codes.md:
--------------------------------------------------------------------------------
1 | # Exit Codes
2 |
3 | `elm-torture` uses exit codes between 32 and 63
4 |
5 | Format
6 |
7 | 0010 0001: One or more suites failed at compile time
8 | 0010 0010: One or more suites failed at run time
9 | 0010 0100: One or more suites should have failed but did not
10 | 0010 1000: Catch all error
11 |
12 | Bitwise or of the above - multiple suites failed for combination of reasons
13 |
--------------------------------------------------------------------------------
/tests/sscce-tests/src/lib/find_suites.rs:
--------------------------------------------------------------------------------
1 | use std::fs;
2 | use std::io;
3 | use std::path::Path;
4 | use std::path::PathBuf;
5 |
6 | #[derive(Debug)]
7 | pub enum Error {
8 | ProvidedPathIsNotDir,
9 | ReadingDir(io::Error),
10 | }
11 |
12 | pub fn find_suites(suites_dir: &Path) -> Result, Error> {
13 | if suites_dir.is_dir() {
14 | if suites_dir.join("elm.json").exists() {
15 | Ok(Box::new([suites_dir.to_path_buf()]))
16 | } else {
17 | let mut suites = vec![];
18 | add_suites(suites_dir, &mut suites)?;
19 | suites.sort_unstable();
20 | Ok(suites.into_boxed_slice())
21 | }
22 | } else {
23 | Err(Error::ProvidedPathIsNotDir)
24 | }
25 | }
26 |
27 | fn add_suites(suites_dir: &Path, suites_list: &mut Vec) -> Result<(), Error> {
28 | let entries = fs::read_dir(suites_dir).map_err(Error::ReadingDir)?;
29 | for entry in entries {
30 | let entry = entry.map_err(Error::ReadingDir)?;
31 | let suite_path = entry.path();
32 | if suite_path.join("elm.json").exists() {
33 | suites_list.push(suite_path);
34 | } else if suite_path.is_dir() {
35 | add_suites(&suite_path, suites_list)?;
36 | }
37 | }
38 | Ok(())
39 | }
40 |
--------------------------------------------------------------------------------
/tests/sscce-tests/src/lib/mod.rs:
--------------------------------------------------------------------------------
1 | pub mod cli;
2 | pub mod config;
3 | pub mod find_suites;
4 | pub mod formatting;
5 | pub mod server_pool;
6 | pub mod suite;
7 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/compiler-tests/lambda-empty-record/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | import Platform
4 | import Util.Programs
5 |
6 | f : { a : Int } -> Int
7 | f {} =
8 | 5
9 |
10 | main : Platform.Program () () ()
11 | main =
12 | Util.Programs.print "Hello World!"
13 |
14 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/compiler-tests/lambda-empty-record/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/core": "1.0.5"
11 | },
12 | "indirect": {
13 | "elm/json": "1.1.3",
14 | "elm/time": "1.0.0"
15 | }
16 | },
17 | "test-dependencies": {
18 | "direct": {},
19 | "indirect": {}
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/compiler-tests/lambda-empty-record/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [
3 | [
4 | "command",
5 | "write",
6 | "Hello World!"
7 | ]
8 | ]
9 | }
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/debug/equal-fails-with-fn/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | import Platform
4 | import Util.Programs
5 | import Util.Subs
6 |
7 |
8 | a : List (a -> a)
9 | a =
10 | [ \x -> x ]
11 |
12 |
13 | main : Platform.Program () () Never
14 | main =
15 | let
16 | v =
17 | if a == a then
18 | "True"
19 | else
20 | "False"
21 |
22 | in
23 | Util.Programs.print v
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/debug/equal-fails-with-fn/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/browser": "1.0.1",
11 | "elm/core": "1.0.5",
12 | "elm/html": "1.0.0"
13 | },
14 | "indirect": {
15 | "elm/json": "1.1.3",
16 | "elm/time": "1.0.0",
17 | "elm/url": "1.0.0",
18 | "elm/virtual-dom": "1.0.2"
19 | }
20 | },
21 | "test-dependencies": {
22 | "direct": {},
23 | "indirect": {}
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/debug/equal-fails-with-fn/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [
3 | [
4 | "command",
5 | "write",
6 | "True"
7 | ]
8 | ],
9 | "run-fails-if": {
10 | "stdlib-variant": ["another"],
11 | "opt-level": ["debug", "dev"]
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/debug/half-baked-log/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | import Platform
4 | import Util.Programs
5 | import Util.Subs
6 |
7 |
8 | main : Platform.Program () () Never
9 | main =
10 | let
11 | _ = Debug.log "half-baked"
12 | in
13 | Util.Programs.noop
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/debug/half-baked-log/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/browser": "1.0.1",
11 | "elm/core": "1.0.5",
12 | "elm/html": "1.0.0"
13 | },
14 | "indirect": {
15 | "elm/json": "1.1.3",
16 | "elm/time": "1.0.0",
17 | "elm/url": "1.0.0",
18 | "elm/virtual-dom": "1.0.2"
19 | }
20 | },
21 | "test-dependencies": {
22 | "direct": {},
23 | "indirect": {}
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/debug/half-baked-log/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [],
3 | "run-fails-if": {
4 | "stdlib-variant": ["another"]
5 | },
6 | "compile-fails-if": {
7 | "opt-level": [
8 | "optimize"
9 | ]
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/debug/log/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | import Platform
4 | import Util.Programs
5 | import Util.Subs
6 |
7 |
8 | type Model
9 | = World
10 |
11 |
12 | main : Platform.Program () Model Never
13 | main =
14 | Platform.worker
15 | { init = \() -> ( Debug.log "hello" World, Cmd.none )
16 | , update = \_ m -> ( m, Cmd.none )
17 | , subscriptions = \_ -> Sub.none
18 | }
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/debug/log/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/browser": "1.0.1",
11 | "elm/core": "1.0.5",
12 | "elm/html": "1.0.0"
13 | },
14 | "indirect": {
15 | "elm/json": "1.1.3",
16 | "elm/time": "1.0.0",
17 | "elm/url": "1.0.0",
18 | "elm/virtual-dom": "1.0.2"
19 | }
20 | },
21 | "test-dependencies": {
22 | "direct": {},
23 | "indirect": {}
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/debug/log/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [],
3 | "logs": "hello: World\n",
4 | "run-fails-if": {
5 | "stdlib-variant": [
6 | "official"
7 | ]
8 | },
9 | "compile-fails-if": {
10 | "opt-level": [
11 | "optimize"
12 | ]
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/echo/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | import Platform
4 | import Util.Cmds
5 | import Util.Subs
6 |
7 | type Msg = Read String
8 |
9 | main : Platform.Program () () Msg
10 | main =
11 | Platform.worker
12 | { init = \() -> ( (), Cmd.none )
13 | , update = update
14 | , subscriptions = \() -> Util.Subs.read Read
15 | }
16 |
17 |
18 | update : Msg -> () -> ((), Cmd Msg)
19 | update (Read s) () =
20 | ( (), Util.Cmds.write s )
21 |
22 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/echo/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/browser": "1.0.1",
11 | "elm/core": "1.0.5",
12 | "elm/html": "1.0.0"
13 | },
14 | "indirect": {
15 | "elm/json": "1.1.3",
16 | "elm/time": "1.0.0",
17 | "elm/url": "1.0.0",
18 | "elm/virtual-dom": "1.0.2"
19 | }
20 | },
21 | "test-dependencies": {
22 | "direct": {},
23 | "indirect": {}
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/echo/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [
3 | [
4 | "subscription",
5 | "read",
6 | "Hello World!"
7 | ],
8 | [
9 | "command",
10 | "write",
11 | "Hello World!"
12 | ]
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/hello-world/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | import Platform
4 | import Util.Programs
5 |
6 |
7 | main : Platform.Program () () ()
8 | main =
9 | Util.Programs.print "Hello World!"
10 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/hello-world/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/core": "1.0.5"
11 | },
12 | "indirect": {
13 | "elm/json": "1.1.3",
14 | "elm/time": "1.0.0"
15 | }
16 | },
17 | "test-dependencies": {
18 | "direct": {},
19 | "indirect": {}
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/hello-world/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [
3 | [
4 | "command",
5 | "write",
6 | "Hello World!"
7 | ]
8 | ]
9 | }
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/http/hello-json/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | import Http
4 | import Platform
5 | import Json.Encode
6 | import Json.Decode
7 | import Util.Http
8 | import Util.Cmds
9 | import Util.Programs exposing (SuiteFlags)
10 |
11 |
12 | getBook : String -> String -> Cmd (Result Http.Error String)
13 | getBook protocol url =
14 | Http.get
15 | { url = protocol ++ url ++ "/some/json/endpoint"
16 | , expect = Http.expectJson identity Json.Decode.value
17 | }
18 | |> Cmd.map (Result.map (Json.Encode.encode 0))
19 |
20 |
21 | update msg () =
22 | ( ()
23 | , Util.Http.actOnHttpResponse msg
24 | )
25 |
26 |
27 | main : Platform.Program (SuiteFlags {}) () (Result Http.Error String)
28 | main =
29 | Platform.worker
30 | { init = \{ suite } -> ( (), getBook suite.protocol suite.url )
31 | , update = update
32 | , subscriptions = \() -> Sub.none
33 | }
34 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/http/hello-json/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/browser": "1.0.1",
11 | "elm/core": "1.0.5",
12 | "elm/html": "1.0.0",
13 | "elm/http": "2.0.0",
14 | "elm/json": "1.1.3"
15 | },
16 | "indirect": {
17 | "elm/bytes": "1.0.8",
18 | "elm/file": "1.0.5",
19 | "elm/time": "1.0.0",
20 | "elm/url": "1.0.0",
21 | "elm/virtual-dom": "1.0.2"
22 | }
23 | },
24 | "test-dependencies": {
25 | "direct": {},
26 | "indirect": {}
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/http/hello-json/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [
3 | [
4 | "command",
5 | "write",
6 | "{\"hello\":\"world\"}"
7 | ]
8 | ],
9 | "network": [
10 | {
11 | "request": {
12 | "method": "get",
13 | "url": "/some/json/endpoint"
14 | },
15 | "response": "{ \"hello\": \"world\" }"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/http/hello-world/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | import Http
4 | import Platform
5 | import Util.Cmds
6 | import Util.Http
7 | import Util.Programs exposing (SuiteFlags)
8 |
9 |
10 | getBook : String -> String -> Cmd (Result Http.Error String)
11 | getBook protocol url =
12 | Http.get
13 | { url = protocol ++ url ++ "/some/http/endpoint"
14 | , expect = Http.expectString identity
15 | }
16 |
17 |
18 | update msg () =
19 | ( ()
20 | , Util.Http.actOnHttpResponse msg
21 | )
22 |
23 |
24 | main : Platform.Program (SuiteFlags {}) () (Result Http.Error String)
25 | main =
26 | Platform.worker
27 | { init = \{ suite } -> ( (), getBook suite.protocol suite.url )
28 | , update = update
29 | , subscriptions = \() -> Sub.none
30 | }
31 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/http/hello-world/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/browser": "1.0.1",
11 | "elm/core": "1.0.5",
12 | "elm/html": "1.0.0",
13 | "elm/http": "2.0.0"
14 | },
15 | "indirect": {
16 | "elm/bytes": "1.0.8",
17 | "elm/file": "1.0.5",
18 | "elm/json": "1.1.3",
19 | "elm/time": "1.0.0",
20 | "elm/url": "1.0.0",
21 | "elm/virtual-dom": "1.0.2"
22 | }
23 | },
24 | "test-dependencies": {
25 | "direct": {},
26 | "indirect": {}
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/http/hello-world/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [
3 | [
4 | "command",
5 | "write",
6 | "Hello, world!"
7 | ]
8 | ],
9 | "network": [
10 | {
11 | "request": {
12 | "method": "get",
13 | "url": "/some/http/endpoint"
14 | },
15 | "response": "Hello, world!"
16 | }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/if-then-else/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | import Platform
4 | import Util.Programs
5 | import Util.Cmds
6 | import Task
7 |
8 |
9 | str : Bool -> String
10 | str b =
11 | if b then
12 | "first"
13 | else
14 | "second"
15 |
16 |
17 | initialCmd =
18 | Cmd.batch
19 | [ Util.Cmds.write (str True)
20 | , Task.perform (\x -> x) (Task.succeed ())
21 | ]
22 |
23 |
24 | main : Platform.Program () () ()
25 | main =
26 | Platform.worker
27 | { init = \() -> ( (), initialCmd )
28 | , update = \() () -> ( (), Util.Cmds.write (str False))
29 | , subscriptions = \() -> Sub.none
30 | }
31 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/if-then-else/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/browser": "1.0.1",
11 | "elm/core": "1.0.5",
12 | "elm/html": "1.0.0"
13 | },
14 | "indirect": {
15 | "elm/json": "1.1.3",
16 | "elm/time": "1.0.0",
17 | "elm/url": "1.0.0",
18 | "elm/virtual-dom": "1.0.2"
19 | }
20 | },
21 | "test-dependencies": {
22 | "direct": {},
23 | "indirect": {}
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/if-then-else/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [
3 | [
4 | "command",
5 | "write",
6 | "first"
7 | ],
8 | [
9 | "command",
10 | "write",
11 | "second"
12 | ]
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/issues/1246/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | import Platform
4 | import Util.Programs
5 |
6 |
7 | toWrite : String
8 | toWrite =
9 | String.fromInt 1000000000000000000000
10 |
11 |
12 | main : Platform.Program () () ()
13 | main =
14 | Util.Programs.print toWrite
15 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/issues/1246/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/browser": "1.0.1",
11 | "elm/core": "1.0.5",
12 | "elm/html": "1.0.0"
13 | },
14 | "indirect": {
15 | "elm/json": "1.1.3",
16 | "elm/time": "1.0.0",
17 | "elm/url": "1.0.0",
18 | "elm/virtual-dom": "1.0.2"
19 | }
20 | },
21 | "test-dependencies": {
22 | "direct": {},
23 | "indirect": {}
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/issues/1246/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [
3 | [
4 | "command",
5 | "write",
6 | "1000000000000000000000"
7 | ]
8 | ],
9 | "run-fails-if": {}
10 | }
11 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/issues/1516/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | import Platform
4 | import Util.Programs
5 |
6 | g : Int -> Int
7 | g =
8 | h
9 |
10 | h : Int -> Int
11 | h n =
12 | if n < 2 then 1 else g (n - 1)
13 |
14 |
15 | toWrite : String
16 | toWrite =
17 | String.fromInt (h 10)
18 |
19 |
20 | main : Platform.Program () () ()
21 | main =
22 | Util.Programs.print toWrite
23 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/issues/1516/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/browser": "1.0.1",
11 | "elm/core": "1.0.5",
12 | "elm/html": "1.0.0"
13 | },
14 | "indirect": {
15 | "elm/json": "1.1.3",
16 | "elm/time": "1.0.0",
17 | "elm/url": "1.0.0",
18 | "elm/virtual-dom": "1.0.2"
19 | }
20 | },
21 | "test-dependencies": {
22 | "direct": {},
23 | "indirect": {}
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/issues/1516/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [
3 | [
4 | "command",
5 | "write",
6 | "1"
7 | ]
8 | ]
9 | }
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/issues/1685/Main.elm:
--------------------------------------------------------------------------------
1 | port module Main exposing (main)
2 |
3 |
4 | import Platform
5 | import Util.Programs
6 |
7 |
8 | type alias TrickyNames =
9 | { static : Int
10 | , default : Int
11 | , interface : Int
12 | , arguments : Int
13 | , this : Int
14 | , prototype : Int
15 | }
16 |
17 |
18 | port echo : TrickyNames -> Cmd msg
19 |
20 |
21 | main : Program () () ()
22 | main =
23 | Util.Programs.sendCmd (echo (TrickyNames 0 1 2 3 4 5))
24 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/issues/1685/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/browser": "1.0.1",
11 | "elm/core": "1.0.5",
12 | "elm/html": "1.0.0"
13 | },
14 | "indirect": {
15 | "elm/json": "1.1.3",
16 | "elm/time": "1.0.0",
17 | "elm/url": "1.0.0",
18 | "elm/virtual-dom": "1.0.2"
19 | }
20 | },
21 | "test-dependencies": {
22 | "direct": {},
23 | "indirect": {}
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/issues/1685/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [
3 | [
4 | "command",
5 | "echo",
6 | {
7 | "arguments": 3,
8 | "default": 1,
9 | "interface": 2,
10 | "prototype": 5,
11 | "static": 0,
12 | "this": 4
13 | }
14 | ]
15 | ]
16 | }
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/issues/1722/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | import Platform
4 | import Util.Programs
5 |
6 |
7 | fromMaybe : ((a -> Maybe b) -> c) -> ((a -> b) -> c)
8 | fromMaybe f =
9 | f << (<<) Just
10 |
11 |
12 | toWrite : String
13 | toWrite =
14 | fromMaybe
15 | (\makeMaybeList ->
16 | let
17 | list =
18 | makeMaybeList 7
19 | |> Maybe.withDefault []
20 | in
21 | List.length list
22 | |> String.fromInt
23 | )
24 | (\x -> [ x, x ])
25 |
26 |
27 | main : Platform.Program () () ()
28 | main =
29 | Util.Programs.print toWrite
30 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/issues/1722/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/browser": "1.0.1",
11 | "elm/core": "1.0.5",
12 | "elm/html": "1.0.0"
13 | },
14 | "indirect": {
15 | "elm/json": "1.1.3",
16 | "elm/time": "1.0.0",
17 | "elm/url": "1.0.0",
18 | "elm/virtual-dom": "1.0.2"
19 | }
20 | },
21 | "test-dependencies": {
22 | "direct": {},
23 | "indirect": {}
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/issues/1722/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [
3 | [
4 | "command",
5 | "write",
6 | "2"
7 | ]
8 | ]
9 | }
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/issues/1753/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | import Array exposing (Array)
4 | import Util.Programs
5 |
6 |
7 | type Msg
8 | = Msg (Array ())
9 |
10 |
11 | main : Program () () Msg
12 | main =
13 | Util.Programs.noop
14 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/issues/1753/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/browser": "1.0.1",
11 | "elm/core": "1.0.5",
12 | "elm/html": "1.0.0"
13 | },
14 | "indirect": {
15 | "elm/json": "1.1.3",
16 | "elm/time": "1.0.0",
17 | "elm/url": "1.0.0",
18 | "elm/virtual-dom": "1.0.2"
19 | }
20 | },
21 | "test-dependencies": {
22 | "direct": {},
23 | "indirect": {}
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/issues/1753/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": []
3 | }
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/issues/1776/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | import Platform
4 | import Task
5 | import Time
6 | import Util.Cmds
7 |
8 |
9 | type Model
10 | = Loading
11 | | Loaded
12 | | End
13 |
14 |
15 | type Msg
16 | = Load
17 | | Tick
18 |
19 |
20 | main : Platform.Program () Model Msg
21 | main =
22 | Platform.worker
23 | { init = init
24 | , update = update
25 | , subscriptions = subscriptions
26 | }
27 |
28 |
29 | init : () -> ( Model, Cmd Msg )
30 | init _ =
31 | ( Loading, Task.perform (\x -> x) (Task.succeed Load) )
32 |
33 |
34 | update : Msg -> Model -> ( Model, Cmd Msg )
35 | update msg _ =
36 | case msg of
37 | Load ->
38 | ( Loaded, Util.Cmds.write "load" )
39 |
40 | Tick ->
41 | ( End, Util.Cmds.write "tick" )
42 |
43 |
44 | subscriptions : Model -> Sub Msg
45 | subscriptions model =
46 | case model of
47 | Loading ->
48 | Sub.none
49 |
50 | Loaded ->
51 | Time.every 100 (\_ -> Tick)
52 |
53 | End ->
54 | Sub.none
55 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/issues/1776/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/core": "1.0.5",
11 | "elm/time": "1.0.0",
12 | "elm/json": "1.1.3"
13 | },
14 | "indirect": {}
15 | },
16 | "test-dependencies": {
17 | "direct": {},
18 | "indirect": {}
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/issues/1776/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [
3 | [
4 | "command",
5 | "write",
6 | "load"
7 | ],
8 | [
9 | "command",
10 | "write",
11 | "tick"
12 | ]
13 | ]
14 | }
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/issues/1813/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | import Platform
4 | import Util.Programs
5 |
6 |
7 | foo : List Int
8 | foo =
9 | let
10 | loop n list =
11 | if n <= 0 then
12 | list
13 |
14 | else
15 | loop (n - 1) ((\() -> n) :: list)
16 | in
17 | List.map (\f -> f ()) <|
18 | loop 3 []
19 |
20 |
21 | toWrite : String
22 | toWrite =
23 | String.join " " (List.map String.fromInt foo)
24 |
25 |
26 | main : Platform.Program () () ()
27 | main =
28 | Util.Programs.print toWrite
29 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/issues/1813/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/browser": "1.0.1",
11 | "elm/core": "1.0.5",
12 | "elm/html": "1.0.0"
13 | },
14 | "indirect": {
15 | "elm/json": "1.1.3",
16 | "elm/time": "1.0.0",
17 | "elm/url": "1.0.0",
18 | "elm/virtual-dom": "1.0.2"
19 | }
20 | },
21 | "test-dependencies": {
22 | "direct": {},
23 | "indirect": {}
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/issues/1813/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [
3 | [
4 | "command",
5 | "write",
6 | "1 2 3"
7 | ]
8 | ],
9 | "run-fails-if": {}
10 | }
11 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/issues/1916/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | import Platform
4 | import Util.Programs
5 |
6 |
7 | type Value r
8 | = Value
9 |
10 |
11 | -- type alias Bug r =
12 | -- Value { r | field : () } -> ()
13 |
14 | type alias Bug r =
15 | Value { r | field : () } -> ()
16 |
17 |
18 | bug : Bug {}
19 | bug Value =
20 | ()
21 |
22 |
23 | main : Platform.Program () () ()
24 | main =
25 | Util.Programs.noop
26 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/issues/1916/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/browser": "1.0.1",
11 | "elm/core": "1.0.5",
12 | "elm/html": "1.0.0"
13 | },
14 | "indirect": {
15 | "elm/json": "1.1.3",
16 | "elm/time": "1.0.0",
17 | "elm/url": "1.0.0",
18 | "elm/virtual-dom": "1.0.2"
19 | }
20 | },
21 | "test-dependencies": {
22 | "direct": {},
23 | "indirect": {}
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/issues/1916/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [],
3 | "compile-fails-if": {}
4 | }
5 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/issues/1964/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | import Platform
4 | import Util.Programs
5 |
6 |
7 | type Type a
8 | = TypeCtor (Type (Wrapper a))
9 |
10 |
11 | type Wrapper a
12 | = Wrapper a
13 |
14 |
15 | foo : Type a -> ()
16 | foo (TypeCtor t) =
17 | foo t
18 |
19 |
20 | main : Platform.Program () () ()
21 | main =
22 | Util.Programs.noop
23 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/issues/1964/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/browser": "1.0.1",
11 | "elm/core": "1.0.5",
12 | "elm/html": "1.0.0"
13 | },
14 | "indirect": {
15 | "elm/json": "1.1.3",
16 | "elm/time": "1.0.0",
17 | "elm/url": "1.0.0",
18 | "elm/virtual-dom": "1.0.2"
19 | }
20 | },
21 | "test-dependencies": {
22 | "direct": {},
23 | "indirect": {}
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/issues/1964/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [],
3 | "compile-fails-if": {}
4 | }
5 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/kill/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | {-| This is not a good test; it will either succeed or go into an infinite
4 | loop.
5 |
6 | However, I cannot think of any other way to test `Process.kill`
7 | -}
8 |
9 | import Platform
10 | import Process
11 | import Task exposing (Task)
12 | import Util.Cmds
13 |
14 |
15 | type Msg
16 | = Kill Process.Id
17 | | Done
18 |
19 |
20 | neverEndingTask : () -> Task Never Never
21 | neverEndingTask () =
22 | Process.sleep 10
23 | |> Task.andThen (\() -> neverEndingTask ())
24 |
25 |
26 | init : ( (), Cmd Msg )
27 | init =
28 | ( ()
29 | , Task.perform Kill (Process.spawn (neverEndingTask ()))
30 | )
31 |
32 |
33 | update : Msg -> () -> ( (), Cmd Msg )
34 | update msg () =
35 | case msg of
36 | Kill id->
37 | ( ()
38 | , Task.perform (\() -> Done) (Process.kill id)
39 | )
40 |
41 | Done ->
42 | ( ()
43 | , Util.Cmds.write "done"
44 | )
45 |
46 |
47 | main : Platform.Program () () Msg
48 | main =
49 | Platform.worker
50 | { init = \() -> init
51 | , update = update
52 | , subscriptions = \_ -> Sub.none
53 | }
54 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/kill/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/core": "1.0.5"
11 | },
12 | "indirect": {
13 | "elm/json": "1.1.3"
14 | }
15 | },
16 | "test-dependencies": {
17 | "direct": {},
18 | "indirect": {}
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/kill/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [
3 | [
4 | "command",
5 | "write",
6 | "done"
7 | ]
8 | ]
9 | }
10 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/map-cmd/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | {-| This is not how Cmd.map is designed to be used.
4 | However, it should test some of the knarly bits of elm/core:Platform
5 | -}
6 |
7 | import Platform
8 | import Task
9 | import Util.Cmds
10 |
11 |
12 | type Msg
13 | = Init Float
14 | | PrintMe String
15 |
16 |
17 | init : ( (), Cmd Msg )
18 | init =
19 | ( ()
20 | , Task.perform (\x -> x) (Task.succeed 7)
21 | |> Cmd.map (\i -> 1 / toFloat i)
22 | |> Cmd.map Init
23 | )
24 |
25 |
26 | update : Msg -> () -> ( (), Cmd Msg )
27 | update msg () =
28 | case msg of
29 | Init f ->
30 | ( ()
31 | , Task.perform String.fromFloat (Task.succeed f)
32 | |> Cmd.map (\s -> PrintMe (String.left 5 s))
33 | )
34 |
35 | PrintMe s ->
36 | ( ()
37 | , Util.Cmds.write s
38 | )
39 |
40 |
41 | main : Platform.Program () () Msg
42 | main =
43 | Platform.worker
44 | { init = \() -> init
45 | , update = update
46 | , subscriptions = \_ -> Sub.none
47 | }
48 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/map-cmd/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/core": "1.0.5"
11 | },
12 | "indirect": {
13 | "elm/json": "1.1.3"
14 | }
15 | },
16 | "test-dependencies": {
17 | "direct": {},
18 | "indirect": {}
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/map-cmd/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [
3 | [
4 | "command",
5 | "write",
6 | "0.142"
7 | ]
8 | ]
9 | }
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/module-name-clash/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main, test2)
2 |
3 | import Module1
4 | import Platform
5 | import Util.Programs
6 |
7 |
8 | test2 : ()
9 | test2 =
10 | Module1.test1
11 |
12 |
13 | main : Platform.Program () () ()
14 | main =
15 | Util.Programs.noop
16 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/module-name-clash/Module1.elm:
--------------------------------------------------------------------------------
1 | module Module1 exposing (test1)
2 |
3 | import Platform
4 | import Util.Programs
5 |
6 |
7 | test1 : ()
8 | test1 =
9 | ()
10 |
11 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/module-name-clash/README.md:
--------------------------------------------------------------------------------
1 | # Module Name Clash
2 |
3 | This SSCCE caused an alpha version of the elm 0.19.0 compiler to fail.
4 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/module-name-clash/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/browser": "1.0.1",
11 | "elm/core": "1.0.5",
12 | "elm/html": "1.0.0"
13 | },
14 | "indirect": {
15 | "elm/json": "1.1.3",
16 | "elm/time": "1.0.0",
17 | "elm/url": "1.0.0",
18 | "elm/virtual-dom": "1.0.2"
19 | }
20 | },
21 | "test-dependencies": {
22 | "direct": {},
23 | "indirect": {}
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/module-name-clash/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": []
3 | }
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/multiple-processes/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | import Platform
4 | import Process
5 | import Task exposing (Task)
6 | import Util.Cmds
7 |
8 |
9 | type Msg
10 | = Init
11 | | Done
12 |
13 |
14 | createProcesses : Int -> Task x ()
15 | createProcesses n =
16 | List.range 1 n
17 | |> List.map toFloat
18 | |> List.map (\i -> Task.andThen Process.sleep (Task.succeed i))
19 | |> List.map Process.spawn
20 | |> Task.sequence
21 | |> Task.map (\_ -> ())
22 |
23 |
24 | init : ( (), Cmd Msg )
25 | init =
26 | ( ()
27 | , createProcesses 10
28 | |> Task.perform (\() -> Init)
29 | )
30 |
31 |
32 | update : Msg -> () -> ( (), Cmd Msg )
33 | update msg counter =
34 | case msg of
35 | Init ->
36 | ( ()
37 | , createProcesses 10
38 | |> Task.perform (\() -> Done)
39 | )
40 |
41 | Done ->
42 | ( (), Util.Cmds.write "done" )
43 |
44 |
45 | main : Platform.Program () () Msg
46 | main =
47 | Platform.worker
48 | { init = \() -> init
49 | , update = update
50 | , subscriptions = \_ -> Sub.none
51 | }
52 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/multiple-processes/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/core": "1.0.5"
11 | },
12 | "indirect": {
13 | "elm/json": "1.1.3"
14 | }
15 | },
16 | "test-dependencies": {
17 | "direct": {},
18 | "indirect": {}
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/multiple-processes/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [
3 | [
4 | "command",
5 | "write",
6 | "done"
7 | ]
8 | ]
9 | }
10 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/multiple-subscriptions/Main.elm:
--------------------------------------------------------------------------------
1 | port module Main exposing (main)
2 |
3 | import Platform
4 | import Util.Cmds
5 | import Util.Subs
6 |
7 |
8 | type Msg
9 | = Read String
10 | | DifferentRead String
11 |
12 |
13 | port differentRead : (String -> msg) -> Sub msg
14 |
15 |
16 | main : Platform.Program () () Msg
17 | main =
18 | Platform.worker
19 | { init = \() -> ( (), Cmd.none )
20 | , update = update
21 | , subscriptions =
22 | \() ->
23 | Sub.batch
24 | [ Util.Subs.read Read
25 | , differentRead DifferentRead
26 | ]
27 | }
28 |
29 |
30 | update : Msg -> () -> ( (), Cmd Msg )
31 | update msg () =
32 | ( ()
33 | , case msg of
34 | Read _ ->
35 | Util.Cmds.write "1"
36 |
37 | DifferentRead _ ->
38 | Util.Cmds.write "2"
39 | )
40 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/multiple-subscriptions/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/browser": "1.0.1",
11 | "elm/core": "1.0.5",
12 | "elm/html": "1.0.0"
13 | },
14 | "indirect": {
15 | "elm/json": "1.1.3",
16 | "elm/time": "1.0.0",
17 | "elm/url": "1.0.0",
18 | "elm/virtual-dom": "1.0.2"
19 | }
20 | },
21 | "test-dependencies": {
22 | "direct": {},
23 | "indirect": {}
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/multiple-subscriptions/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [
3 | [
4 | "subscription",
5 | "read",
6 | ""
7 | ],
8 | [
9 | "command",
10 | "write",
11 | "1"
12 | ],
13 | [
14 | "subscription",
15 | "differentRead",
16 | ""
17 | ],
18 | [
19 | "command",
20 | "write",
21 | "2"
22 | ],
23 | [
24 | "subscription",
25 | "differentRead",
26 | ""
27 | ],
28 | [
29 | "command",
30 | "write",
31 | "2"
32 | ],
33 | [
34 | "subscription",
35 | "differentRead",
36 | ""
37 | ],
38 | [
39 | "command",
40 | "write",
41 | "2"
42 | ],
43 | [
44 | "subscription",
45 | "differentRead",
46 | ""
47 | ],
48 | [
49 | "command",
50 | "write",
51 | "2"
52 | ],
53 | [
54 | "subscription",
55 | "read",
56 | ""
57 | ],
58 | [
59 | "command",
60 | "write",
61 | "1"
62 | ],
63 | [
64 | "subscription",
65 | "differentRead",
66 | ""
67 | ],
68 | [
69 | "command",
70 | "write",
71 | "2"
72 | ]
73 | ]
74 | }
75 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/numeric-package/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | import Json.Encode
4 | import Json.Value
5 | import Platform
6 | import Util.Programs
7 |
8 |
9 | jsonValue : Json.Value.JsonValue
10 | jsonValue =
11 | Json.Value.NumericValue 0.5
12 |
13 |
14 | toWrite : String
15 | toWrite =
16 | jsonValue
17 | |> Json.Value.encode
18 | |> Json.Encode.encode 1
19 |
20 |
21 | main : Platform.Program () () ()
22 | main =
23 | Util.Programs.print toWrite
24 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/numeric-package/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "1602/json-value": "3.0.1",
11 | "elm/browser": "1.0.1",
12 | "elm/core": "1.0.5",
13 | "elm/html": "1.0.0",
14 | "elm/json": "1.1.3"
15 | },
16 | "indirect": {
17 | "elm/time": "1.0.0",
18 | "elm/url": "1.0.0",
19 | "elm/virtual-dom": "1.0.2"
20 | }
21 | },
22 | "test-dependencies": {
23 | "direct": {},
24 | "indirect": {}
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/numeric-package/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [
3 | [
4 | "command",
5 | "write",
6 | "0.5"
7 | ]
8 | ]
9 | }
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/parser/README:
--------------------------------------------------------------------------------
1 | See https://github.com/elm/compiler/issues/1374
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/parser/back-slash-char/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | import Platform
4 | import Util.Programs
5 |
6 | backSlashChar : Char
7 | backSlashChar =
8 | '\\'
9 |
10 | toWrite : String
11 | toWrite =
12 | String.fromChar backSlashChar
13 |
14 |
15 | main : Platform.Program () () ()
16 | main =
17 | Util.Programs.print toWrite
18 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/parser/back-slash-char/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/browser": "1.0.1",
11 | "elm/core": "1.0.5",
12 | "elm/html": "1.0.0"
13 | },
14 | "indirect": {
15 | "elm/json": "1.1.3",
16 | "elm/time": "1.0.0",
17 | "elm/url": "1.0.0",
18 | "elm/virtual-dom": "1.0.2"
19 | }
20 | },
21 | "test-dependencies": {
22 | "direct": {},
23 | "indirect": {}
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/parser/back-slash-char/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [
3 | [
4 | "command",
5 | "write",
6 | "\\"
7 | ]
8 | ]
9 | }
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/parser/nested-module-record/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | import Platform
4 | import Util.Programs
5 | import Nested.Module
6 |
7 |
8 | toWrite : String
9 | toWrite =
10 | String.fromInt Nested.Module.record.theAnswer
11 |
12 |
13 | main : Platform.Program () () ()
14 | main =
15 | Util.Programs.print toWrite
16 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/parser/nested-module-record/Nested/Module.elm:
--------------------------------------------------------------------------------
1 | module Nested.Module exposing (record)
2 |
3 |
4 | record : { theAnswer : Int }
5 | record =
6 | { theAnswer = 42 }
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/parser/nested-module-record/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/browser": "1.0.1",
11 | "elm/core": "1.0.5",
12 | "elm/html": "1.0.0"
13 | },
14 | "indirect": {
15 | "elm/json": "1.1.3",
16 | "elm/time": "1.0.0",
17 | "elm/url": "1.0.0",
18 | "elm/virtual-dom": "1.0.2"
19 | }
20 | },
21 | "test-dependencies": {
22 | "direct": {},
23 | "indirect": {}
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/parser/nested-module-record/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [
3 | [
4 | "command",
5 | "write",
6 | "42"
7 | ]
8 | ]
9 | }
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/random/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | import Platform
4 | import Random
5 | import Util.Cmds
6 | import Util.Subs
7 |
8 |
9 | type Msg
10 | = Rand Int
11 |
12 |
13 | randomCmd : Cmd Msg
14 | randomCmd =
15 | Random.generate Rand (Random.int 0 1000)
16 |
17 |
18 | main : Platform.Program () Int Msg
19 | main =
20 | Platform.worker
21 | { init = \() -> ( 0, randomCmd )
22 | , update = update
23 | , subscriptions = \_ -> Sub.none
24 | }
25 |
26 |
27 | update : Msg -> Int -> ( Int, Cmd Msg )
28 | update (Rand i) count =
29 | ( count + 1
30 | , if count < 10 then
31 | Cmd.batch
32 | [ Util.Cmds.write (String.fromInt i)
33 | , randomCmd
34 | ]
35 |
36 | else
37 | Cmd.none
38 | )
39 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/random/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/browser": "1.0.1",
11 | "elm/core": "1.0.5",
12 | "elm/html": "1.0.0",
13 | "elm/random": "1.0.0"
14 | },
15 | "indirect": {
16 | "elm/json": "1.1.3",
17 | "elm/time": "1.0.0",
18 | "elm/url": "1.0.0",
19 | "elm/virtual-dom": "1.0.2"
20 | }
21 | },
22 | "test-dependencies": {
23 | "direct": {},
24 | "indirect": {}
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/random/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [
3 | ["command", "write", "347"],
4 | ["command", "write", "748"],
5 | ["command", "write", "339"],
6 | ["command", "write", "292"],
7 | ["command", "write", "56"],
8 | ["command", "write", "708"],
9 | ["command", "write", "476"],
10 | ["command", "write", "157"],
11 | ["command", "write", "411"],
12 | ["command", "write", "377"]
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/sleep/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 |
4 | import Platform
5 | import Process
6 | import Task
7 | import Util.Cmds
8 |
9 |
10 | type Msg
11 | = Init
12 |
13 |
14 | init : ( (), Cmd Msg )
15 | init =
16 | ( ()
17 | , Task.perform (\() -> Init) (Process.sleep 1)
18 | )
19 |
20 |
21 | update : Msg -> () -> ( (), Cmd Msg )
22 | update msg () =
23 | case msg of
24 | Init ->
25 | ( ()
26 | , Util.Cmds.write "done"
27 | )
28 |
29 |
30 | main : Platform.Program () () Msg
31 | main =
32 | Platform.worker
33 | { init = \() -> init
34 | , update = update
35 | , subscriptions = \_ -> Sub.none
36 | }
37 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/sleep/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/core": "1.0.5"
11 | },
12 | "indirect": {
13 | "elm/json": "1.1.3"
14 | }
15 | },
16 | "test-dependencies": {
17 | "direct": {},
18 | "indirect": {}
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/sleep/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [
3 | [
4 | "command",
5 | "write",
6 | "done"
7 | ]
8 | ]
9 | }
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/subscription-order/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | {-| SSCCE based on
4 | -}
5 |
6 | import Task
7 | import Time exposing (Posix, Zone)
8 | import Util.Cmds
9 |
10 |
11 | type Model
12 | = Loading
13 | | HasZone Zone
14 | | Done
15 |
16 |
17 | type Msg
18 | = NewZone Zone
19 | | Tick Posix
20 |
21 |
22 | main =
23 | Platform.worker
24 | { init = init
25 | , update = update
26 | , subscriptions = subscriptions
27 | }
28 |
29 |
30 | init : () -> ( Model, Cmd Msg )
31 | init _ =
32 | ( Loading, Task.perform NewZone Time.here )
33 |
34 |
35 | update : Msg -> Model -> ( Model, Cmd Msg )
36 | update msg _ =
37 | case msg of
38 | NewZone zone ->
39 | ( HasZone zone, Util.Cmds.write "got zone" )
40 |
41 | Tick _ ->
42 | ( Done, Util.Cmds.write "got tick" )
43 |
44 |
45 | subscriptions : Model -> Sub Msg
46 | subscriptions model =
47 | case model of
48 | Loading ->
49 | Sub.none
50 |
51 | HasZone _ ->
52 | Time.every 100 Tick
53 |
54 | Done ->
55 | Sub.none
56 |
57 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/subscription-order/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/core": "1.0.5",
11 | "elm/time": "1.0.0",
12 | "elm/json": "1.1.3"
13 | },
14 | "indirect": {}
15 | },
16 | "test-dependencies": {
17 | "direct": {},
18 | "indirect": {}
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/subscription-order/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [
3 | [
4 | "command",
5 | "write",
6 | "got zone"
7 | ],
8 | [
9 | "command",
10 | "write",
11 | "got tick"
12 | ]
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/time/every/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | import Platform
4 | import Time
5 | import Util.Cmds
6 |
7 |
8 | type Msg
9 | = Init
10 | | Time1
11 | | Time2
12 |
13 |
14 | type Item
15 | = One
16 | | Two
17 | | Three
18 | | Four
19 |
20 |
21 | type alias Model =
22 | ( Item, List Item )
23 |
24 |
25 | update : Msg -> Model -> ( Model, Cmd Msg )
26 | update msg ( item1, items ) =
27 | case msg of
28 | Init ->
29 | ( ( Two, item1 :: items )
30 | , Cmd.none
31 | )
32 |
33 | Time1 ->
34 | ( ( Three, item1 :: items )
35 | , Util.Cmds.write "1"
36 | )
37 |
38 | Time2 ->
39 | ( ( Four, item1 :: items )
40 | , Util.Cmds.write "2"
41 | )
42 |
43 |
44 | subscriptions : Model -> Sub Msg
45 | subscriptions ( item, _ ) =
46 | let
47 | subs =
48 | Sub.batch
49 | [ Time.every 30 (\_ -> Time1)
50 | , Time.every 100 (\_ -> Time2)
51 | ]
52 | in
53 | case item of
54 | -- Get app in sync with 300ms intervals
55 | One ->
56 | Time.every 300 (\_ -> Init)
57 |
58 | Two ->
59 | subs
60 |
61 | Three ->
62 | subs
63 |
64 | Four ->
65 | Sub.none
66 |
67 |
68 | main : Platform.Program () Model Msg
69 | main =
70 | Platform.worker
71 | { init = \() -> ( ( One, [] ), Cmd.none )
72 | , update = update
73 | , subscriptions = subscriptions
74 | }
75 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/time/every/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/core": "1.0.5",
11 | "elm/time": "1.0.0"
12 | },
13 | "indirect": {
14 | "elm/json": "1.1.3"
15 | }
16 | },
17 | "test-dependencies": {
18 | "direct": {},
19 | "indirect": {
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/time/every/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [
3 | [
4 | "command",
5 | "write",
6 | "1"
7 | ],
8 | [
9 | "command",
10 | "write",
11 | "1"
12 | ],
13 | [
14 | "command",
15 | "write",
16 | "1"
17 | ],
18 | [
19 | "command",
20 | "write",
21 | "2"
22 | ]
23 | ],
24 | "skip-run-if": {
25 | "platform": ["macos"]
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/time/here/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | import Platform
4 | import Task
5 | import Time
6 | import Util.Cmds
7 |
8 |
9 | type Msg
10 | = Init Time.Zone
11 |
12 |
13 | init : ( (), Cmd Msg )
14 | init =
15 | ( ()
16 | , Task.perform Init Time.here
17 | )
18 |
19 |
20 | update : Msg -> () -> ( (), Cmd Msg )
21 | update msg () =
22 | case msg of
23 | Init z ->
24 | ( ()
25 | , if z == Time.customZone (3*60) [] then
26 | Util.Cmds.write "good - zone is as expected"
27 |
28 | else
29 | Util.Cmds.error [ "Debug.toString z" ]
30 | )
31 |
32 |
33 | main : Platform.Program () () Msg
34 | main =
35 | Platform.worker
36 | { init = \() -> init
37 | , update = update
38 | , subscriptions = \_ -> Sub.none
39 | }
40 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/time/here/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/core": "1.0.5",
11 | "elm/time": "1.0.0"
12 | },
13 | "indirect": {
14 | "elm/json": "1.1.3"
15 | }
16 | },
17 | "test-dependencies": {
18 | "direct": {},
19 | "indirect": {
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/time/here/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [
3 | [
4 | "command",
5 | "write",
6 | "good - zone is as expected"
7 | ]
8 | ],
9 | "skip-run-if": {
10 | // TZ environment variable only works with posix.
11 | "platform": ["windows"]
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/time/zone-name/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | import Platform
4 | import Task
5 | import Time
6 | import Util.Cmds
7 |
8 |
9 | type Msg
10 | = Init Time.ZoneName
11 |
12 |
13 | init : ( (), Cmd Msg )
14 | init =
15 | ( ()
16 | , Task.perform Init Time.getZoneName
17 | )
18 |
19 |
20 | update : Msg -> () -> ( (), Cmd Msg )
21 | update msg () =
22 | case msg of
23 | Init z ->
24 | ( ()
25 | , if z == Time.Name "Asia/Bahrain" then
26 | Util.Cmds.write "good - zone is as expected"
27 |
28 | else
29 | Util.Cmds.error [ "Debug.toString z" ]
30 | )
31 |
32 |
33 | main : Platform.Program () () Msg
34 | main =
35 | Platform.worker
36 | { init = \() -> init
37 | , update = update
38 | , subscriptions = \_ -> Sub.none
39 | }
40 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/time/zone-name/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/core": "1.0.5",
11 | "elm/time": "1.0.0"
12 | },
13 | "indirect": {
14 | "elm/json": "1.1.3"
15 | }
16 | },
17 | "test-dependencies": {
18 | "direct": {},
19 | "indirect": {
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/time/zone-name/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [
3 | [
4 | "command",
5 | "write",
6 | "good - zone is as expected"
7 | ]
8 | ],
9 | "skip-run-if": {
10 | // TZ environment variable only works with posix.
11 | "platform": ["windows"]
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/update-loop/Main.elm:
--------------------------------------------------------------------------------
1 | module Main exposing (main)
2 |
3 | import Platform
4 | import Task
5 | import Util.Cmds
6 |
7 |
8 | init : ( Int, Cmd () )
9 | init =
10 | ( 0
11 | , Task.perform (\x -> x) (Task.succeed ())
12 | )
13 |
14 |
15 | update : a -> Int -> ( Int, Cmd () )
16 | update _ counter =
17 | ( counter + 1
18 | , if counter > 10 then
19 | Cmd.none
20 |
21 | else
22 | Cmd.batch
23 | [ Util.Cmds.write (String.fromInt counter)
24 | , Task.perform (\x -> x) (Task.succeed ())
25 | ]
26 | )
27 |
28 |
29 | main : Platform.Program () Int ()
30 | main =
31 | Platform.worker
32 | { init = \() -> init
33 | , update = update
34 | , subscriptions = \_ -> Sub.none
35 | }
36 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/update-loop/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | ".",
5 | "../util"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/core": "1.0.5"
11 | },
12 | "indirect": {
13 | "elm/json": "1.1.3"
14 | }
15 | },
16 | "test-dependencies": {
17 | "direct": {},
18 | "indirect": {}
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/update-loop/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "ports": [
3 | [
4 | "command",
5 | "write",
6 | "0"
7 | ],
8 | [
9 | "command",
10 | "write",
11 | "1"
12 | ],
13 | [
14 | "command",
15 | "write",
16 | "2"
17 | ],
18 | [
19 | "command",
20 | "write",
21 | "3"
22 | ],
23 | [
24 | "command",
25 | "write",
26 | "4"
27 | ],
28 | [
29 | "command",
30 | "write",
31 | "5"
32 | ],
33 | [
34 | "command",
35 | "write",
36 | "6"
37 | ],
38 | [
39 | "command",
40 | "write",
41 | "7"
42 | ],
43 | [
44 | "command",
45 | "write",
46 | "8"
47 | ],
48 | [
49 | "command",
50 | "write",
51 | "9"
52 | ],
53 | [
54 | "command",
55 | "write",
56 | "10"
57 | ]
58 | ]
59 | }
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/util/Util/Cmds.elm:
--------------------------------------------------------------------------------
1 | port module Util.Cmds exposing (error, write)
2 |
3 |
4 | port write : String -> Cmd never
5 |
6 |
7 | port error : List String -> Cmd never
8 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/util/Util/Http.elm:
--------------------------------------------------------------------------------
1 | module Util.Http exposing (actOnHttpResponse)
2 |
3 | import Http
4 | import Util.Cmds
5 |
6 |
7 | actOnHttpResponse : Result Http.Error String -> Cmd never
8 | actOnHttpResponse resp =
9 | case resp of
10 | Ok str ->
11 | Util.Cmds.write str
12 |
13 | Err (Http.BadUrl str) ->
14 | Util.Cmds.error [ "Bad Url", str ]
15 |
16 | Err Http.Timeout ->
17 | Util.Cmds.error [ "Timeout" ]
18 |
19 | Err Http.NetworkError ->
20 | Util.Cmds.error [ "NetworkError" ]
21 |
22 | Err (Http.BadStatus i) ->
23 | Util.Cmds.error [ "BadStatus", String.fromInt i ]
24 |
25 | Err (Http.BadBody str) ->
26 | Util.Cmds.error [ "BadBody", str ]
27 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/util/Util/Programs.elm:
--------------------------------------------------------------------------------
1 | module Util.Programs exposing (SuiteFlags, noop, print, sendCmd)
2 |
3 | import Platform
4 | import Util.Cmds
5 |
6 |
7 | type alias SuiteFlags a =
8 | { a
9 | | suite :
10 | { url : String
11 | , protocol : String
12 | }
13 | }
14 |
15 |
16 | sendCmd : Cmd a -> Platform.Program () () a
17 | sendCmd cmd =
18 | Platform.worker
19 | { init = \() -> ( (), cmd )
20 | , update = \_ () -> ( (), Cmd.none )
21 | , subscriptions = \() -> Sub.none
22 | }
23 |
24 |
25 | print : String -> Platform.Program () () a
26 | print string =
27 | sendCmd (Util.Cmds.write string)
28 |
29 |
30 | noop : Platform.Program () () a
31 | noop =
32 | sendCmd Cmd.none
33 |
--------------------------------------------------------------------------------
/tests/sscce-tests/suite/util/Util/Subs.elm:
--------------------------------------------------------------------------------
1 | port module Util.Subs exposing (read)
2 |
3 |
4 | port read : (String -> msg) -> Sub msg
5 |
--------------------------------------------------------------------------------
/tests/tests/FromElmTest/Lazy.elm:
--------------------------------------------------------------------------------
1 | module FromElmTest.Lazy exposing
2 | ( Lazy
3 | , force
4 | , lazy
5 | , map
6 | )
7 |
8 | {-| This library lets you delay a computation until later.
9 |
10 | This implementation is private to elm-test and has non-essential functions removed.
11 | If you need a complete Lazy List implementation, one can be found on elm-package.
12 |
13 | -}
14 |
15 |
16 | {-| A wrapper around a value that will be lazily evaluated.
17 | -}
18 | type Lazy a
19 | = Lazy (() -> a)
20 | | Evaluated a
21 |
22 |
23 | {-| Delay the evaluation of a value until later. For example, maybe we will
24 | need to generate a very long list and find its sum, but we do not want to do
25 | it unless it is absolutely necessary.
26 |
27 | lazySum : Lazy Int
28 | lazySum =
29 | lazy (\() -> sum <| List.range 1 1000000)
30 |
31 | Now we only pay for `lazySum` if we actually need it.
32 |
33 | -}
34 | lazy : (() -> a) -> Lazy a
35 | lazy thunk =
36 | Lazy thunk
37 |
38 |
39 | {-| Force the evaluation of a lazy value. This means we only pay for the
40 | computation when we need it. Here is a rather contrived example.
41 |
42 | lazySum : Lazy Int
43 | lazySum =
44 | lazy (\() -> List.sum <| List.range 1 1000000)
45 |
46 | sums : ( Int, Int, Int )
47 | sums =
48 | ( force lazySum, force lazySum, force lazySum )
49 |
50 | -}
51 | force : Lazy a -> a
52 | force piece =
53 | case piece of
54 | Evaluated a ->
55 | a
56 |
57 | Lazy thunk ->
58 | thunk ()
59 |
60 |
61 | {-| Lazily apply a function to a lazy value.
62 |
63 | lazySum : Lazy Int
64 | lazySum =
65 | map List.sum (lazy (\() -> <| List.range 1 1000000)
66 |
67 | The resulting lazy value will create a big list and sum it up when it is
68 | finally forced.
69 |
70 | -}
71 | map : (a -> b) -> Lazy a -> Lazy b
72 | map f a =
73 | lazy (\() -> f (force a))
74 |
--------------------------------------------------------------------------------
/tests/tests/FromElmTest/MicroRandomExtra.elm:
--------------------------------------------------------------------------------
1 | module FromElmTest.MicroRandomExtra exposing (bool, frequency, lengthString, oneIn, sample)
2 |
3 | {-| Most of these are copied from elm-random-extra.
4 | -}
5 |
6 | import Array exposing (Array)
7 | import Random exposing (..)
8 | import String
9 |
10 |
11 | lengthString : Generator Char -> Int -> Generator String
12 | lengthString charGenerator stringLength =
13 | list stringLength charGenerator
14 | |> map String.fromList
15 |
16 |
17 | bool : Generator Bool
18 | bool =
19 | int 0 1 |> map ((==) 0)
20 |
21 |
22 | sample : List a -> Generator (Maybe a)
23 | sample =
24 | let
25 | find k ys =
26 | case ys of
27 | [] ->
28 | Nothing
29 |
30 | z :: zs ->
31 | if k == 0 then
32 | Just z
33 |
34 | else
35 | find (k - 1) zs
36 | in
37 | \xs -> map (\i -> find i xs) (int 0 (List.length xs - 1))
38 |
39 |
40 | oneIn : Int -> Generator Bool
41 | oneIn n =
42 | map ((==) 1) (int 1 n)
43 |
44 |
45 | frequency : ( Float, Generator a ) -> List ( Float, Generator a ) -> Generator a
46 | frequency firstPair restPairs =
47 | let
48 | total =
49 | List.sum <| List.map (abs << Tuple.first) (firstPair :: restPairs)
50 |
51 | pick ( k, g ) restChoices n =
52 | if n <= k then
53 | g
54 |
55 | else
56 | case restChoices of
57 | [] ->
58 | g
59 |
60 | next :: rest ->
61 | pick next rest (n - k)
62 | in
63 | float 0 total |> andThen (pick firstPair restPairs)
64 |
--------------------------------------------------------------------------------
/tests/tests/FromElmTest/RoseTree.elm:
--------------------------------------------------------------------------------
1 | module FromElmTest.RoseTree exposing (RoseTree(..), addChild, map, root, singleton)
2 |
3 | {-| RoseTree implementation in Elm using Lazy Lists.
4 |
5 | This implementation is private to elm-test and has non-essential functions removed.
6 | If you need a complete RoseTree implementation, one can be found on elm-package.
7 |
8 | -}
9 |
10 | import FromElmTest.Lazy.List as LazyList exposing (LazyList, cons)
11 |
12 |
13 | {-| RoseTree type.
14 | A rosetree is a tree with a root whose children are themselves rosetrees.
15 | -}
16 | type RoseTree a
17 | = Rose a (LazyList (RoseTree a))
18 |
19 |
20 | {-| Make a singleton rosetree.
21 | -}
22 | singleton : a -> RoseTree a
23 | singleton a =
24 | Rose a LazyList.empty
25 |
26 |
27 | {-| Get the root of a rosetree.
28 | -}
29 | root : RoseTree a -> a
30 | root (Rose a _) =
31 | a
32 |
33 |
34 | {-| Add a child to the rosetree.
35 | -}
36 | addChild : RoseTree a -> RoseTree a -> RoseTree a
37 | addChild child (Rose a c) =
38 | Rose a (cons child c)
39 |
40 |
41 | {-| Map a function over a rosetree.
42 | -}
43 | map : (a -> b) -> RoseTree a -> RoseTree b
44 | map f (Rose a c) =
45 | Rose (f a) (LazyList.map (map f) c)
46 |
--------------------------------------------------------------------------------
/tests/tests/Test/Equality.elm:
--------------------------------------------------------------------------------
1 | module Test.Equality exposing (tests)
2 |
3 | import Basics exposing (..)
4 | import Expect
5 | import Fuzz
6 | import Maybe exposing (..)
7 | import Test exposing (..)
8 |
9 |
10 | type Different
11 | = A String
12 | | B (List Int)
13 |
14 |
15 | tests : Test
16 | tests =
17 | let
18 | diffTests =
19 | describe "ADT equality"
20 | [ test "As eq" <| \() -> Expect.equal True (A "a" == A "a")
21 | , test "Bs eq" <| \() -> Expect.equal True (B [ 1 ] == B [ 1 ])
22 | , test "A left neq" <| \() -> Expect.equal True (A "a" /= B [ 1 ])
23 | , test "A right neq" <| \() -> Expect.equal True (B [ 1 ] /= A "a")
24 | ]
25 |
26 | recordTests =
27 | describe "Record equality"
28 | [ test "empty same" <| \() -> Expect.equal True ({} == {})
29 | , test "ctor same" <| \() -> Expect.equal True ({ field = Just 3 } == { field = Just 3 })
30 | , test "ctor same, special case" <| \() -> Expect.equal True ({ ctor = Just 3 } == { ctor = Just 3 })
31 | , test "ctor diff" <| \() -> Expect.equal True ({ field = Just 3 } /= { field = Nothing })
32 | , test "ctor diff, special case" <| \() -> Expect.equal True ({ ctor = Just 3 } /= { ctor = Nothing })
33 | ]
34 |
35 | listTests =
36 | describe "List equality"
37 | [ fuzz2 (Fuzz.intRange 100 10000) (Fuzz.intRange 100 10000) "Simple comparison" <|
38 | \size1 size2 ->
39 | Expect.equal
40 | (size1 == size2)
41 | (List.range 0 size1 == List.range 0 size2)
42 | ]
43 | in
44 | describe "Equality Tests" [ diffTests, recordTests, listTests ]
45 |
--------------------------------------------------------------------------------
/tests/tests/Test/Html/Events.elm:
--------------------------------------------------------------------------------
1 | module Test.Html.Events exposing (jsonDecoderTests)
2 |
3 | import Expect
4 | import Fuzz
5 | import Html.Events as E
6 | import Json.Decode
7 | import Json.Encode
8 | import Test exposing (..)
9 |
10 |
11 | eventJson : { value : String, checked : Bool, keyCode : Int } -> Json.Encode.Value
12 | eventJson { value, checked, keyCode } =
13 | Json.Encode.object
14 | [ ( "target"
15 | , Json.Encode.object
16 | [ ( "value", Json.Encode.string value )
17 | , ( "checked", Json.Encode.bool checked )
18 | ]
19 | )
20 | , ( "keyCode", Json.Encode.int keyCode )
21 | ]
22 |
23 |
24 | jsonDecoderTests : Test
25 | jsonDecoderTests =
26 | let
27 | testDecoder value decoder expected =
28 | case Json.Decode.decodeValue decoder value of
29 | Ok a ->
30 | Expect.equal a expected
31 |
32 | Err _ ->
33 | Expect.fail "Could not decode"
34 | in
35 | describe "Html.Event custom decoders"
36 | [ fuzz Fuzz.string "targetValue" <|
37 | \value ->
38 | testDecoder
39 | (eventJson { value = value, checked = False, keyCode = 0 })
40 | E.targetValue
41 | value
42 | , fuzz Fuzz.bool "targetChecked" <|
43 | \checked ->
44 | testDecoder
45 | (eventJson { value = "", checked = checked, keyCode = 0 })
46 | E.targetChecked
47 | checked
48 | , fuzz Fuzz.int "keyCode " <|
49 | \keyCode ->
50 | testDecoder
51 | (eventJson { value = "", checked = False, keyCode = keyCode })
52 | E.keyCode
53 | keyCode
54 | ]
55 |
--------------------------------------------------------------------------------
/tests/vdom-tests/.eslintignore:
--------------------------------------------------------------------------------
1 | elm.js
2 | elm-stuff
3 |
--------------------------------------------------------------------------------
/tests/vdom-tests/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "extends": ["eslint:recommended"],
4 | "rules": {
5 | "curly": "error",
6 | "no-restricted-syntax": [
7 | "error",
8 | {
9 | "selector": "SequenceExpression",
10 | "message": "The comma operator is confusing and a common mistake. Don’t use it!"
11 | }
12 | ]
13 | },
14 | "overrides": [
15 | {
16 | "files": ["*.js"],
17 | "excludedFiles": ["patch.js"],
18 | "env": {
19 | "node": true,
20 | "es2020": true
21 | },
22 | "rules": {
23 | "no-var": "error",
24 | "object-shorthand": "error",
25 | "one-var": ["error", "never"],
26 | "prefer-arrow-callback": "error",
27 | "prefer-const": "error",
28 | "prefer-destructuring": [
29 | "error",
30 | {
31 | "object": true,
32 | "array": false
33 | }
34 | ],
35 | "prefer-exponentiation-operator": "error",
36 | "prefer-numeric-literals": "error",
37 | "prefer-object-spread": "error",
38 | "prefer-promise-reject-errors": "error",
39 | "prefer-regex-literals": "error",
40 | "prefer-rest-params": "error",
41 | "prefer-spread": "error",
42 | "prefer-template": "error"
43 | }
44 | },
45 | {
46 | "files": ["patch.js"],
47 | "env": {
48 | "browser": true
49 | },
50 | "rules": {
51 | "one-var": [
52 | "error",
53 | {
54 | "var": "always",
55 | "separateRequires": true
56 | }
57 | ]
58 | }
59 | },
60 | {
61 | "files": "tests/**/*.js",
62 | "extends": ["plugin:jest/recommended", "plugin:jest/style"],
63 | "env": {
64 | "browser": true
65 | }
66 | }
67 | ]
68 | }
69 |
--------------------------------------------------------------------------------
/tests/vdom-tests/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | elm-stuff
3 | elm.js
4 |
--------------------------------------------------------------------------------
/tests/vdom-tests/.prettierignore:
--------------------------------------------------------------------------------
1 | .vscode
2 | elm.js
3 | elm*.json
4 | package*.json
5 | elm-stuff
6 |
--------------------------------------------------------------------------------
/tests/vdom-tests/.prettierrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "proseWrap": "never"
3 | }
4 |
--------------------------------------------------------------------------------
/tests/vdom-tests/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2021 Simon Lydell
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/tests/vdom-tests/bin.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | const fs = require("fs");
3 | const runReplacements = require(".");
4 |
5 | function run(argv) {
6 | if (argv.includes("--help") || argv.includes("-h") || argv.length === 0) {
7 | console.log(help());
8 | process.exit(0);
9 | }
10 |
11 | if (argv.length > 1) {
12 | console.error(`Expected one argument, but got ${argv.length}.`);
13 | process.exit(1);
14 | }
15 |
16 | const [file] = argv;
17 |
18 | try {
19 | overwrite(file, runReplacements);
20 | } catch (error) {
21 | console.error(error.message);
22 | process.exit(1);
23 | }
24 |
25 | console.log("Success!");
26 | }
27 |
28 | function overwrite(file, transform) {
29 | fs.writeFileSync(file, transform(fs.readFileSync(file, "utf8")));
30 | }
31 |
32 | function help() {
33 | return `
34 | Usage: elm-safe-virtual-dom path/to/elm/output.js
35 |
36 | path/to/elm/output.js:
37 |
38 | - Should contain the output of \`elm make\`.
39 | - Should NOT be minified.
40 | - The Elm code should use \`import Browser\`.
41 |
42 | This tool overwrites the file, changing parts of the JavaScript code.
43 | `.trimStart();
44 | }
45 |
46 | run(process.argv.slice(2));
47 |
--------------------------------------------------------------------------------
/tests/vdom-tests/elm-tooling.json:
--------------------------------------------------------------------------------
1 | {
2 | "tools": {
3 | "elm": "0.19.1",
4 | "elm-format": "0.8.5",
5 | "elm-json": "0.2.10"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/tests/vdom-tests/elm.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "application",
3 | "source-directories": [
4 | "src",
5 | "tests/elm"
6 | ],
7 | "elm-version": "0.19.1",
8 | "dependencies": {
9 | "direct": {
10 | "elm/browser": "1.0.2",
11 | "elm/core": "1.0.5",
12 | "elm/html": "1.0.0",
13 | "elm/json": "1.1.3",
14 | "elm/random": "1.0.0",
15 | "elm/svg": "1.0.1",
16 | "elm/url": "1.0.0",
17 | "elm-community/array-extra": "2.3.0",
18 | "elm-community/random-extra": "3.2.0",
19 | "elm-explorations/markdown": "1.0.0",
20 | "mdgriffith/elm-ui": "1.1.8"
21 | },
22 | "indirect": {
23 | "elm/time": "1.0.0",
24 | "elm/virtual-dom": "1.0.2"
25 | }
26 | },
27 | "test-dependencies": {
28 | "direct": {},
29 | "indirect": {}
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/tests/vdom-tests/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "elm-safe-virtual-dom",
3 | "version": "0.0.1",
4 | "bin": "./bin.js",
5 | "scripts": {
6 | "build": "elm make src/Main.elm --output elm.js && node bin.js elm.js",
7 | "debug": "elm make src/Main.elm --output elm.js --debug && node bin.js elm.js",
8 | "optimize": "elm make src/Main.elm --output elm.js --optimize && node bin.js elm.js",
9 | "sandbox": "elm make src/Sandbox.elm --output elm.js && node bin.js elm.js",
10 | "sandbox-debug": "elm make src/Sandbox.elm --output elm.js --debug && node bin.js elm.js",
11 | "sandbox-simple": "elm make src/SandboxSimple.elm --output elm.js && node bin.js elm.js",
12 | "only-html": "elm make src/OnlyHtml.elm --output elm.js && node bin.js elm.js",
13 | "keylist": "elm make src/KeyList.elm --output elm.js && node bin.js elm.js",
14 | "elm-ui": "elm make src/ElmUi.elm --output elm.js && node bin.js elm.js",
15 | "test": "eslint . --report-unused-disable-directives && prettier --check . && jest"
16 | },
17 | "dependencies": {
18 | "elm-tooling": "^1.2.0"
19 | },
20 | "devDependencies": {
21 | "eslint": "^7.21.0",
22 | "eslint-plugin-jest": "^24.3.2",
23 | "jest": "^26.6.3",
24 | "prettier": "^2.2.1"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/tests/vdom-tests/serve.json:
--------------------------------------------------------------------------------
1 | {
2 | "headers": [
3 | {
4 | "source": "*",
5 | "headers": [
6 | {
7 | "key": "Cross-Origin-Opener-Policy",
8 | "value": "same-origin"
9 | },
10 | {
11 | "key": "Cross-Origin-Embedder-Policy",
12 | "value": "require-corp"
13 | }
14 | ]
15 | }
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/tests/vdom-tests/src/ElmUi.elm:
--------------------------------------------------------------------------------
1 | module ElmUi exposing (main)
2 |
3 | import Browser
4 | import Element exposing (Element)
5 | import Element.Border
6 | import Element.Input
7 |
8 |
9 | main : Program () Model Msg
10 | main =
11 | Browser.sandbox
12 | { init = init
13 | , view = Element.layout [] << view
14 | , update = update
15 | }
16 |
17 |
18 | type alias Model =
19 | { count : Int
20 | , text : String
21 | }
22 |
23 |
24 | init : Model
25 | init =
26 | { count = 0
27 | , text = ""
28 | }
29 |
30 |
31 | type Msg
32 | = Next
33 | | Input String
34 |
35 |
36 | update : Msg -> Model -> Model
37 | update msg model =
38 | case msg of
39 | Next ->
40 | { model | count = model.count + 1 }
41 |
42 | Input text ->
43 | { model | text = String.replace "!" "" text }
44 |
45 |
46 | view : Model -> Element Msg
47 | view model =
48 | Element.column [ Element.spacing 8, Element.width (Element.maximum 400 Element.fill) ]
49 | [ Element.text "Count: "
50 | , Element.text (String.fromInt model.count)
51 | , Element.Input.button [] { onPress = Just Next, label = Element.text "Nästa" }
52 | , Element.Input.multiline
53 | [ Element.width Element.fill
54 | , Element.padding 8
55 | , Element.Border.color (Element.rgb 0 0 0)
56 | ]
57 | { onChange = Input
58 | , text = model.text
59 | , placeholder = Nothing
60 | , label = Element.Input.labelAbove [] (Element.text "Text:")
61 | , spellcheck = True
62 | }
63 | , Element.paragraph [] [ Element.text model.text ]
64 | ]
65 |
--------------------------------------------------------------------------------
/tests/vdom-tests/src/OnlyHtml.elm:
--------------------------------------------------------------------------------
1 | module OnlyHtml exposing (main)
2 |
3 | import Html
4 |
5 |
6 | main =
7 | Html.text "Hello"
8 |
--------------------------------------------------------------------------------
/tests/vdom-tests/src/Sandbox.elm:
--------------------------------------------------------------------------------
1 | module Sandbox exposing (main)
2 |
3 | import Browser
4 | import Html exposing (..)
5 | import Html.Attributes
6 | import Html.Events exposing (..)
7 |
8 |
9 | main : Program () Model Msg
10 | main =
11 | Browser.sandbox
12 | { init = init
13 | , view = view
14 | , update = update
15 | }
16 |
17 |
18 | type alias Model =
19 | { count : Int
20 | , text : String
21 | }
22 |
23 |
24 | init : Model
25 | init =
26 | { count = 0
27 | , text = ""
28 | }
29 |
30 |
31 | type Msg
32 | = Next
33 | | Input String
34 |
35 |
36 | update : Msg -> Model -> Model
37 | update msg model =
38 | case msg of
39 | Next ->
40 | { model | count = model.count + 1 }
41 |
42 | Input text ->
43 | { model | text = String.replace "!" "" text }
44 |
45 |
46 | view : Model -> Html Msg
47 | view model =
48 | div []
49 | [ text "Count: "
50 | , if model.count |> modBy 2 |> (==) 0 then
51 | text (String.fromInt model.count)
52 |
53 | else
54 | Html.em [] [ text (String.fromInt model.count) ]
55 | , button [ onClick Next ] [ text "Nästa" ]
56 | , input [ onInput Input, Html.Attributes.value model.text ] []
57 | , input [ Html.Attributes.type_ "checkbox", Html.Attributes.checked True, onCheck (always Next) ] []
58 | , a [ Html.Attributes.href "" ] [ Html.text "a" ]
59 | ]
60 |
--------------------------------------------------------------------------------
/tests/vdom-tests/src/SandboxSimple.elm:
--------------------------------------------------------------------------------
1 | module SandboxSimple exposing (main)
2 |
3 | import Browser
4 | import Html
5 | import Html.Attributes
6 |
7 |
8 | main =
9 | Browser.sandbox
10 | { init = ()
11 | , view =
12 | always
13 | (Html.div
14 | [ Html.Attributes.hidden True
15 | , Html.Attributes.class ""
16 | ]
17 | [ Html.text "Hello" ]
18 | )
19 | , update = always identity
20 | }
21 |
--------------------------------------------------------------------------------
/tests/vdom-tests/tests/elm/App.elm:
--------------------------------------------------------------------------------
1 | module App exposing (main)
2 |
3 | import Browser
4 | import Browser.Navigation as Nav
5 | import Html exposing (..)
6 | import Html.Attributes exposing (href)
7 | import Url exposing (Url)
8 |
9 |
10 | main : Program () Model Msg
11 | main =
12 | Browser.application
13 | { init = init
14 | , view = view
15 | , update = update
16 | , subscriptions = subscriptions
17 | , onUrlRequest = UrlRequested
18 | , onUrlChange = UrlChanged
19 | }
20 |
21 |
22 | type alias Model =
23 | { key : Nav.Key
24 | , url : Url
25 | }
26 |
27 |
28 | init : () -> Url -> Nav.Key -> ( Model, Cmd Msg )
29 | init () url key =
30 | ( { key = key
31 | , url = url
32 | }
33 | , Cmd.none
34 | )
35 |
36 |
37 | type Msg
38 | = UrlRequested Browser.UrlRequest
39 | | UrlChanged Url.Url
40 |
41 |
42 | update : Msg -> Model -> ( Model, Cmd Msg )
43 | update msg model =
44 | case msg of
45 | UrlRequested urlRequest ->
46 | case urlRequest of
47 | Browser.Internal url ->
48 | ( model, Nav.pushUrl model.key (Url.toString url) )
49 |
50 | Browser.External href ->
51 | ( model, Nav.load href )
52 |
53 | UrlChanged url ->
54 | ( { model | url = url }
55 | , Cmd.none
56 | )
57 |
58 |
59 | subscriptions : Model -> Sub Msg
60 | subscriptions _ =
61 | Sub.none
62 |
63 |
64 | view : Model -> Browser.Document Msg
65 | view model =
66 | { title = "Application Title"
67 | , body =
68 | [ div []
69 | [ text (Url.toString model.url)
70 | , a [ href "/test" ] [ text "link" ]
71 | ]
72 | ]
73 | }
74 |
--------------------------------------------------------------------------------