-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'atomvm:master' into w23/add-enif_monitor
- Loading branch information
Showing
18 changed files
with
395 additions
and
19 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 |
---|---|---|
|
@@ -31,8 +31,6 @@ jobs: | |
|
||
matrix: | ||
idf-version: | ||
- 4.2.4 | ||
- 4.3.5 | ||
- 4.4.4 | ||
- 5.0.2 | ||
- 5.1-rc1 | ||
|
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
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
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
31 changes: 31 additions & 0 deletions
31
src/platforms/emscripten/tests/cypress/e2e/atomvm.spec.cy.js
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,31 @@ | ||
/* | ||
* This file is part of AtomVM. | ||
* | ||
* Copyright 2023 by Paul Guyot <[email protected]> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later | ||
*/ | ||
describe("atomvm", () => { | ||
beforeEach(() => { | ||
cy.visit("/tests/src/test_atomvm.html"); | ||
}); | ||
|
||
it("should return platform", () => { | ||
cy.get("#platform").should("contain", "emscripten"); | ||
}); | ||
it("should compute pi with a reasonable error", () => { | ||
cy.get("#pierror").should("contain", "true"); | ||
}); | ||
}); |
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,72 @@ | ||
% | ||
% This file is part of AtomVM. | ||
% | ||
% Copyright 2023 Paul Guyot <[email protected]> | ||
% | ||
% Licensed under the Apache License, Version 2.0 (the "License"); | ||
% you may not use this file except in compliance with the License. | ||
% You may obtain a copy of the License at | ||
% | ||
% http://www.apache.org/licenses/LICENSE-2.0 | ||
% | ||
% Unless required by applicable law or agreed to in writing, software | ||
% distributed under the License is distributed on an "AS IS" BASIS, | ||
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
% See the License for the specific language governing permissions and | ||
% limitations under the License. | ||
% | ||
% SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later | ||
% | ||
|
||
-module(test_atomvm). | ||
-export([start/0]). | ||
|
||
start() -> | ||
erlang:display({?MODULE, ?LINE}), | ||
Platform = atomvm:platform(), | ||
erlang:display({?MODULE, ?LINE}), | ||
Random = atomvm:random(), | ||
erlang:display({?MODULE, ?LINE}), | ||
PI = pi_by_random(), | ||
PIError = abs((PI - 3.141592653589793) / 3.141592653589793), | ||
PIErrorThreshold = PIError < 0.01, | ||
erlang:display({?MODULE, ?LINE}), | ||
emscripten:run_script( | ||
[ | ||
<<"document.querySelector('#platform').append('">>, | ||
atom_to_list(Platform), | ||
<<"');">>, | ||
<<"document.querySelector('#random').append('">>, | ||
integer_to_list(Random), | ||
<<"');">>, | ||
<<"document.querySelector('#pi').append('">>, | ||
float_to_list(PI), | ||
<<"');">>, | ||
<<"document.querySelector('#pierror').append('">>, | ||
atom_to_list(PIErrorThreshold), | ||
<<"');">> | ||
], | ||
[main_thread, async] | ||
), | ||
loop(). | ||
|
||
loop() -> | ||
receive | ||
after infinity -> ok | ||
end. | ||
|
||
pi_by_random() -> | ||
pi_by_random(100000, 0, 0). | ||
|
||
pi_by_random(0, AccHit, AccTotal) -> | ||
4 * AccHit / AccTotal; | ||
pi_by_random(N, AccHit, AccTotal) -> | ||
X = atomvm:random(), | ||
Y = atomvm:random(), | ||
SqDistance = (X - 16#80000000) * (X - 16#80000000) + (Y - 16#80000000) * (Y - 16#80000000), | ||
NewAccHit = | ||
case SqDistance > (16#80000000 * 16#80000000) of | ||
true -> AccHit; | ||
false -> AccHit + 1 | ||
end, | ||
pi_by_random(N - 1, NewAccHit, AccTotal + 1). |
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,44 @@ | ||
<!-- | ||
This file is part of AtomVM. | ||
Copyright 2023 Paul Guyot <[email protected]> | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later | ||
--> | ||
<!doctype html> | ||
<html lang="en" dir="ltr"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
</head> | ||
<body> | ||
<div id="platform"></div> | ||
<div id="random"></div> | ||
<div id="pi"></div> | ||
<div id="pierror"></div> | ||
<script> | ||
// Arguments are loaded using fetch API. | ||
// wasm_webserver serves under /tests/build/ files in src/platform/escripten/build/tests/src subdirectory | ||
// and under /build/ files in build/ subdirectory. | ||
var Module = { | ||
arguments: [ | ||
"/tests/build/test_atomvm.beam", | ||
"/build/libs/estdlib/src/estdlib.avm", | ||
"/build/libs/eavmlib/src/eavmlib.avm", | ||
], | ||
}; | ||
</script> | ||
<script async src="/AtomVM.js"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.