Skip to content

Commit

Permalink
Merge branch 'master' into locales
Browse files Browse the repository at this point in the history
  • Loading branch information
gdotdesign committed Sep 6, 2023
2 parents a8ecd78 + 4383b5d commit d28c7a3
Show file tree
Hide file tree
Showing 79 changed files with 2,309 additions and 1,631 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: crystal-lang/install-crystal@v1

- name: Checkout source code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install dependencies
run: shards install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/ci-nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: CI Nightly

on:
schedule:
- cron: "0 6 * * 1"
workflow_dispatch:

jobs:
test:
name: Test
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}

steps:
- name: Install Crystal
uses: crystal-lang/install-crystal@v1
with:
crystal: nightly

- name: Download source
uses: actions/checkout@v4

- name: Install dependencies
run: shards install

- name: Run specs
run: crystal spec --error-on-warnings --error-trace

- name: Build the binary
run: shards build --error-on-warnings --error-trace

- name: Run core specs (Firefox)
working-directory: ./core/tests
run: ../../bin/mint test -b firefox

- name: Run core specs (Google Chrome)
working-directory: ./core/tests
run: ../../bin/mint test -b chrome

- name: Check formatting (Mint)
working-directory: ./core
run: ../bin/mint format --check

- name: Check formatting (Mint tests)
working-directory: ./core/tests
run: ../../bin/mint format --check

- name: Check formatting (Crystal)
run: crystal tool format --check

- name: Run ameba
run: bin/ameba
7 changes: 2 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ on:
types: [opened, synchronize, reopened]
release:
types: [published]
schedule:
- cron: "0 6 * * 1"
workflow_dispatch:

jobs:
Expand All @@ -18,17 +16,16 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
crystal: [latest, nightly]
runs-on: ${{ matrix.os }}

steps:
- name: Install Crystal
uses: crystal-lang/install-crystal@v1
with:
crystal: ${{ matrix.crystal }}
crystal: latest

- name: Download source
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install dependencies
run: shards install
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/lib/
/bin/
/.shards/
.vscode
193 changes: 193 additions & 0 deletions core/source/Math.mint
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
/* Mathematical functions. */
module Math {
/* Euler's number and the base of natural logarithms; approximately `2.718`. */
const E = `Math.E`

/* Natural logarithm of `10`; approximately `2.303`. */
const LN10 = `Math.LN10`

/* Natural logarithm of `2`; approximately `0.693`. */
const LN2 = `Math.LN2`

/* Base-10 logarithm of `E`; approximately `0.434`. */
const LOG10E = `Math.LOG10E`

/* Base-2 logarithm of `E`; approximately `1.443`. */
const LOG2E = `Math.LOG2E`

/* Ratio of a circle's circumference to its diameter; approximately `3.14159`. */
const PI = `Math.PI`

/* Square root of `0.5`; approximately `0.707`. */
const SQRT12 = `Math.SQRT1_2`

/* Square root of `2`; approximately `1.414`. */
const SQRT2 = `Math.SQRT2`

/*
Returns the absolute value of the given number.
Expand All @@ -10,6 +34,51 @@ module Math {
`Math.abs(#{number})`
}

/* Returns the inverse cosine of the given angle in radians */
fun acos (number : Number) : Number {
`Math.acos(#{number})`
}

/* Returns the inverse hyperbolic cosine of the given angle in radians */
fun acosh (number : Number) : Number {
`Math.acosh(#{number})`
}

/* Returns the inverse sine of the given angle in radians */
fun asin (number : Number) : Number {
`Math.asin(#{number})`
}

/* Returns the inverse hyperbolic sine of the given angle in radians */
fun asinh (number : Number) : Number {
`Math.asinh(#{number})`
}

/* Returns the inverse tangent of the given angle in radians */
fun atan (number : Number) : Number {
`Math.atan(#{number})`
}

/* Returns the angle in the plane (in radians) between the positive x-axis and the ray from (0, 0) to the point (x, y) */
fun atan2 (y : Number, x : Number) : Number {
`Math.atan2(#{y}, #{x})`
}

/* Returns the inverse hyperbolic tangent of the given angle in radians */
fun atanh (number : Number) : Number {
`Math.atanh(#{number})`
}

/*
Returns the cubic root of the given number
Math.cbrt(1) == 1
Math.cbrt(64) == 4
*/
fun cbrt (number : Number) : Number {
`Math.cbrt(#{number})`
}

/*
Returns the smallest integer greater than or equal to the given number.
Expand All @@ -29,6 +98,41 @@ module Math {
Math.min(upper, Math.max(lower, value))
}

/*
Returns the number of leading zero bits in the 32-bit binary representation of a number
00000000000000000000000000000100
Math.clz32(4) == 29
*/
fun clz32 (number : Number) : Number {
`Math.clz32(#{number})`
}

/* Returns the cosine of the given angle in radians */
fun cos (number : Number) : Number {
`Math.cos(#{number})`
}

/* Returns the hyperbolic cosine of the given angle in radians */
fun cosh (number : Number) : Number {
`Math.cosh(#{number})`
}

/* Returns the value of `Math:E` raised to the power x, where x is the given number */
fun exp (x : Number) : Number {
`Math.exp(#{x})`
}

/*
Returns the value of `Math:E` to the power x, minus 1
Math.exp(2) == 7.38905609893065
Math.expm1(2) == 6.38905609893065
*/
fun expm1 (x : Number) : Number {
`Math.expm1(#{x})`
}

/*
Returns the largest integer less than or equal to the given number.
Expand All @@ -48,6 +152,65 @@ module Math {
`Number((#{b} - (Math.floor(#{b} / #{a}) * #{a})).toPrecision(8))`
}

/* Returns the nearest 32-bit single precision float representation of the given number. */
fun fround (number : Number) : Number {
`Math.fround(#{number})`
}

/*
Returns the square root of the sum of squares of its arguments.
Math.hypot(3, 4) == 5
*/
fun hypot (a : Number, b : Number) : Number {
`Math.hypot(#{a}, #{b})`
}

/*
Returns the result using C-like 32-bit multiplication of the two parameters.
Math.imul(3, 4) == 12
*/
fun imul (a : Number, b : number) : Number {
`Math.imul(#{a}, #{b})`
}

/*
Returns natural logarithm (base e) of the given value
Math.log(1) == 0
*/
fun log (number : Number) : Number {
`Math.log(#{number})`
}

/*
Returns natural logarithm (base 10) of the given value
Math.log10(100) == 10
*/
fun log10 (number : Number) : Number {
`Math.log10(#{number})`
}

/*
Returns natural logarithm (base e) of the given value, plus 1
Math.log1p(1) == 0
*/
fun log1p (number : Number) : Number {
`Math.log1p(#{number})`
}

/*
Returns natural logarithm (base 2) of the given value
Math.log2(8) == 3
*/
fun log2 (number : Number) : Number {
`Math.log2(#{number})`
}

/*
Returns the highest-valued number from the arguments.
Expand Down Expand Up @@ -98,6 +261,26 @@ module Math {
`Math.round(#{number})`
}

/*
Returns the sign of the given number (1 or -1)
Math.sign(5) == 1
Math.sign(-5) == -1
*/
fun sign (number : Number) : Number {
`Math.sign(#{number})`
}

/* Calculates the sine of the given angle in radians */
fun sin (value : Number) : Number {
`Math.sin(#{value})`
}

/* Calculates the hyperbolic sine of the given angle in radians */
fun sinh (number : Number) : Number {
`Math.sinh(#{number})`
}

/*
Returns the square root of the given number
Expand All @@ -107,6 +290,16 @@ module Math {
`Math.sqrt(#{value})`
}

/* Calculates the tangent of the given angle in radians */
fun tan (number : Number) {
`Math.tan(#{number})`
}

/* Calculates the hyperbolic tangent of the given angle in radians */
fun tanh (number : Number) : Number {
`Math.tanh(#{number})`
}

/*
Returns the integer part of a number by removing any fractional digits.
Expand Down
14 changes: 7 additions & 7 deletions core/source/Object/Decode.mint
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Object.Decode {
/*
Decodes the object as an `Array` using the given decoder.
Object.Decode.array(`["A", "B"]`, Object.Decode.string, ) == Result::Ok(["a", "b"])
Object.Decode.array(`["A", "B"]`, Object.Decode.string) == Result::Ok(["a", "b"])
*/
fun array (
input : Object,
Expand All @@ -25,7 +25,7 @@ module Object.Decode {
Decodes a field from an object using the given decoder.
Object.Decode.field(
"field", Object.Decode.string, `{field: "Value"}`) == Result::Ok("Value")
`{field: "Value"}`, "field", Object.Decode.string) == Result::Ok("Value")
*/
fun field (
input : Object,
Expand All @@ -38,8 +38,8 @@ module Object.Decode {
/*
Decodes the object as a `Maybe(a)` using the given decoder.
Object.Decode.maybe(Object.Decode.String, `"A"`) == Result::Ok(Maybe::Just("A"))
Object.Decode.maybe(Object.Decode.String, `null`) == Result::Ok(Maybe::Nothing)
Object.Decode.maybe(`"A"`, Object.Decode.String) == Result::Ok(Maybe::Just("A"))
Object.Decode.maybe(`null`, Object.Decode.String) == Result::Ok(Maybe::Nothing)
*/
fun maybe (
input : Object,
Expand All @@ -51,7 +51,7 @@ module Object.Decode {
/*
Decodes the object as a `Number`
Object.Decode.boolean(`0`) == Result::Ok(0)
Object.Decode.number(`0`) == Result::Ok(0)
*/
fun number (input : Object) : Result(Object.Error, Number) {
`Decoder.number(#{input})`
Expand All @@ -60,7 +60,7 @@ module Object.Decode {
/*
Decodes the object as a `String`
Object.Decode.boolean(`"A"`) == Result::Ok("A")
Object.Decode.string(`"A"`) == Result::Ok("A")
*/
fun string (input : Object) : Result(Object.Error, String) {
`Decoder.string(#{input})`
Expand All @@ -69,7 +69,7 @@ module Object.Decode {
/*
Decodes the object as a `Time`
Object.Decode.boolean(`"new Date()"`)
Object.Decode.time(`"new Date()"`)
*/
fun time (input : Object) : Result(Object.Error, Time) {
`Decoder.time(#{input})`
Expand Down
Loading

0 comments on commit d28c7a3

Please sign in to comment.