Skip to content

Commit

Permalink
Improved simplification of units, closes #37
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp committed Mar 30, 2017
1 parent cf64905 commit 2707028
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
],
"dependencies": {
"purescript-prelude": "^2.4.0",
"purescript-quantities": "^3.6.0",
"purescript-quantities": "^4.0.0",
"purescript-parsing": "^3.2.1",
"purescript-maps": "^2.1.2",
"jquery.terminal": "=1.0.15",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "insect",
"version": "3.0.0",
"version": "4.0.0",
"description": "REPL-style scientific calculator with full support for physical units",
"author": "David Peter <[email protected]>",
"license": "MIT",
Expand Down
13 changes: 9 additions & 4 deletions test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -654,8 +654,8 @@ main = runTest do

let expectOutput' = expectOutput initialEnvironment

suite "Integration" do
test "Simple" do
suite "Integration tests" do
test "Simple input" do
expectOutput' "3m" "3m"
expectOutput' "3m" " 3.0 meter "

Expand Down Expand Up @@ -701,15 +701,20 @@ main = runTest do
expectOutput' "4" "round(3.9)"
expectOutput' "3" "round(3.1)"

test "Simple" do
test "Unit simplification" do
expectOutput' "36000Mbit" "5Mbit/s * 2h"
expectOutput' "2500cm²" "5cm · 5m"
expectOutput' "0.2km" "120km/h*6s"

test "Examples" do
expectOutput' "1080" "1920/16*9"
expectOutput' "4294967296" "2^32"
expectOutput' "0.512957" "sqrt(1.4^2 + 1.5^2) * cos(pi/3)^2"

expectOutput' "2.5min" "2min + 30s"
expectOutput' "150s" "2min + 30s -> sec"
expectOutput' "904779000000km³" "4/3 * pi * (6000km)³"
expectOutput' "58800kg·m·cm/s²" "40kg * 9.8m/s² * 150cm"
expectOutput' "588m²·kg/s²" "40kg * 9.8m/s² * 150cm"
expectOutput' "0.5" "sin(30°)"

expectOutput' "26.8224m/s" "60mph -> m/s"
Expand Down

0 comments on commit 2707028

Please sign in to comment.