-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create tests * Create CI file * Replace dynamic with term type * Fix non suported map comprehension
- Loading branch information
1 parent
cd153c1
commit efcd0a6
Showing
3 changed files
with
119 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
name: CI | ||
|
||
"on": | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- "*" | ||
workflow_dispatch: {} | ||
merge_group: | ||
|
||
concurrency: | ||
group: ${{github.workflow}}-${{github.ref}} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
ci: | ||
name: OTP-${{matrix.otp-version}} | ||
|
||
runs-on: ${{matrix.os}} | ||
|
||
strategy: | ||
matrix: | ||
otp-version: [24, 25, 26] | ||
os: [ubuntu-24.04] | ||
|
||
steps: | ||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
|
||
- uses: erlef/setup-beam@b9c58b0450cd832ccdb3c17cc156a47065d2114f # v1.18.1 | ||
id: setup-beam | ||
with: | ||
otp-version: ${{matrix.otp-version}} | ||
rebar3-version: 3.23.0 | ||
|
||
- name: Restore _build | ||
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | ||
with: | ||
path: _build | ||
key: "_build-cache-for\ | ||
-os-${{runner.os}}\ | ||
-otp-${{steps.setup-beam.outputs.otp-version}}\ | ||
-rebar3-${{steps.setup-beam.outputs.rebar3-version}}\ | ||
-hash-${{hashFiles('rebar.lock')}}-${{hashFiles('rebar.config')}}" | ||
|
||
- name: Restore rebar3's cache | ||
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | ||
with: | ||
path: ~/.cache/rebar3 | ||
key: "rebar3-cache-for\ | ||
-os-${{runner.os}}\ | ||
-otp-${{steps.setup-beam.outputs.otp-version}}\ | ||
-rebar3-${{steps.setup-beam.outputs.rebar3-version}}\ | ||
-hash-${{hashFiles('rebar.lock')}}" | ||
|
||
- name: Test | ||
run: | | ||
rebar3 ct |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
-module(json_polyfill_SUITE). | ||
-behaviour(ct_suite). | ||
-include_lib("stdlib/include/assert.hrl"). | ||
-compile([export_all, nowarn_export_all]). | ||
|
||
all() -> | ||
[encode, decode]. | ||
|
||
encode(Config) when is_list(Config) -> | ||
ExpectA = [91,<<"null">>,44, | ||
["{", | ||
[[34,<<"foo">>,34],58,34,<<"bar">>,34], | ||
[[44,[34,<<"bar">>,34],58,34,<<"baz">>,34]], | ||
"}"], | ||
93], | ||
ExpectB = [91,<<"null">>,44, | ||
["{", | ||
[[34,<<"bar">>,34],58,34,<<"baz">>,34], | ||
[[44,[34,<<"foo">>,34],58,34,<<"bar">>,34]], | ||
"}"], | ||
93], | ||
Result = json:encode([null, #{foo => bar, bar => baz}]), | ||
?assert(Result =:= ExpectA orelse Result =:= ExpectB). | ||
|
||
decode(Config) when is_list(Config) -> | ||
ExpectA = [null,#{<<"bar">> => <<"baz">>,<<"foo">> => <<"bar">>}], | ||
ExpectB = [null,#{<<"foo">> => <<"bar">>,<<"bar">> => <<"baz">>}], | ||
Result = json:decode(iolist_to_binary( | ||
[91,<<"null">>,44, | ||
["{", | ||
[[34,<<"foo">>,34],58,34,<<"bar">>,34], | ||
[[44,[34,<<"bar">>,34],58,34,<<"baz">>,34]], | ||
"}"], | ||
93] | ||
)), | ||
?assert(Result =:= ExpectA orelse Result =:= ExpectB). |