Skip to content

Commit a8569bf

Browse files
committed
update playground
1 parent 4c83082 commit a8569bf

File tree

125 files changed

+114686
-100784
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+114686
-100784
lines changed

docs/js-demo/compiler_test.js

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
require('./exports.js')
2+
3+
var output = ocaml.compile('let a = 3')
4+
5+
// var json = require('../../package.json')
6+
var header = `Generated by BUCKLESCRIPT`
7+
8+
var failed = false
9+
10+
/**
11+
* @return {string|bool} return string if successful otherwise return false
12+
* @param {*} input
13+
*/
14+
function test(input) {
15+
var output = JSON.parse(ocaml.compile(input))
16+
if (output && output.js_code) {
17+
var js_code = output.js_code
18+
if (js_code.includes(header)) {
19+
return js_code
20+
} else {
21+
failed = true
22+
return false
23+
}
24+
} else {
25+
failed = true
26+
return false
27+
}
28+
}
29+
30+
var fs = require('fs')
31+
var p = require('path')
32+
var example = p.join(__dirname, 'examples')
33+
var files = fs.readdirSync(example)
34+
35+
files.forEach(function (x) {
36+
37+
if (x.endsWith('.ml')) {
38+
var path = p.join(example, x)
39+
var content = fs.readFileSync(path, 'utf8')
40+
console.log(`testing ${path}`)
41+
var output
42+
if (output = test(content)) {
43+
console.log("successful")
44+
} else {
45+
console.error("failed")
46+
}
47+
}
48+
49+
})
50+
51+
if(failed){
52+
console.error('not all tests passed')
53+
process.exit(2)
54+
}
+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
open Js
22
let () =
33
[| 1; 2; 3; 4 |]
4-
|> Array.filter (fun [@bs] x -> x > 2)
5-
|> Array.mapi (fun [@bs] x i -> x + i)
6-
|> Array.reduce (fun [@bs] x y -> x + y) 0
4+
|> Array.filter (fun x -> x > 2)
5+
|> Array.mapi (fun x i -> x + i)
6+
|> Array.reduce (fun x y -> x + y) 0
77
|> log

docs/js-demo/exports.js

+23,057-20,371
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/js-demo/pre_load.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)