(check-expect (uniparse "abc") '(normalize-unit 'abc)) (check-expect (uniparse "234") '(make-numeric-quantity 234)) (check-expect (uniparse "abc^234") '(power (normalize-unit 'abc) 234)) (check-expect (uniparse "234^567") '(power (make-numeric-quantity 234) 567)) (check-expect (uniparse "abc+de") '(add (normalize-unit 'abc) (normalize-unit 'de))) (check-expect (uniparse "abc-de") '(subtract (normalize-unit 'abc) (normalize-unit 'de))) (check-expect (uniparse "abc+de+fg") '(add (add (normalize-unit 'abc) (normalize-unit 'de)) (normalize-unit 'fg))) (check-expect (uniparse "abc+de-fg") '(subtract (add (normalize-unit 'abc) (normalize-unit 'de)) (normalize-unit 'fg))) (check-expect (uniparse "abc-de+fg") '(add (subtract (normalize-unit 'abc) (normalize-unit 'de)) (normalize-unit 'fg))) (check-expect (uniparse "(abc)") '(normalize-unit 'abc)) (check-expect (uniparse "(abc*def)") '(multiply (normalize-unit 'abc) (normalize-unit 'def))) (check-expect (uniparse "(abc/def)") '(divide (normalize-unit 'abc) (normalize-unit 'def))) (check-expect (uniparse "(abc*def*gh)") '(multiply (multiply (normalize-unit 'abc) (normalize-unit 'def)) (normalize-unit 'gh))) (check-expect (uniparse "(abc/def*gh)") '(multiply (divide (normalize-unit 'abc) (normalize-unit 'def)) (normalize-unit 'gh))) (check-expect (uniparse "(abc*def/gh)") '(divide (multiply (normalize-unit 'abc) (normalize-unit 'def)) (normalize-unit 'gh))) (check-expect (uniparse "(abc def/gh)") '(divide (multiply (normalize-unit 'abc) (normalize-unit 'def)) (normalize-unit 'gh))) (check-expect (uniparse "(abc+def/gh)") '(add (normalize-unit 'abc) (divide (normalize-unit 'def) (normalize-unit 'gh)))) (check-expect (uniparse "(abc/def+gh)") '(add (divide (normalize-unit 'abc) (normalize-unit 'def)) (normalize-unit 'gh))) (check-expect (uniparse "((abc))") '(normalize-unit 'abc)) (check-expect (uniparse "(((abc)))") '(normalize-unit 'abc)) (check-expect (uniparse "((abc)def)") '(multiply (normalize-unit 'abc) (normalize-unit 'def))) (check-expect (uniparse "abc def^234 gh") '(multiply (multiply (normalize-unit 'abc) (power (normalize-unit 'def) 234)) (normalize-unit 'gh))) (check-expect (uniparse "abc+def") '(add (normalize-unit 'abc) (normalize-unit 'def))) (check-expect (uniparse "abc+def+gh") '(add (add (normalize-unit 'abc) (normalize-unit 'def)) (normalize-unit 'gh))) (check-expect (uniparse "abc+def-gh") '(subtract (add (normalize-unit 'abc) (normalize-unit 'def)) (normalize-unit 'gh))) (check-expect (uniparse "abc-def+gh") '(add (subtract (normalize-unit 'abc) (normalize-unit 'def)) (normalize-unit 'gh))) (check-expect (uniparse "abc-def-gh") '(subtract (subtract (normalize-unit 'abc) (normalize-unit 'def)) (normalize-unit 'gh))) (check-expect (uniparse "abc+def*gh") '(add (normalize-unit 'abc) (multiply (normalize-unit 'def) (normalize-unit 'gh)))) (check-expect (uniparse "abc*def+gh") '(add (multiply (normalize-unit 'abc) (normalize-unit 'def)) (normalize-unit 'gh))) (check-expect (uniparse "abc*def+gh*ijk") '(add (multiply (normalize-unit 'abc) (normalize-unit 'def)) (multiply (normalize-unit 'gh) (normalize-unit 'ijk)))) (check-expect (uniparse "abc/def+gh*ijk") '(add (divide (normalize-unit 'abc) (normalize-unit 'def)) (multiply (normalize-unit 'gh) (normalize-unit 'ijk)))) (check-expect (uniparse "abc+def/gh*ijk") '(add (normalize-unit 'abc) (multiply (divide (normalize-unit 'def) (normalize-unit 'gh)) (normalize-unit 'ijk)))) (check-expect (uniparse "abc+def/gh+ijk") '(add (add (normalize-unit 'abc) (divide (normalize-unit 'def) (normalize-unit 'gh))) (normalize-unit 'ijk))) (check-expect (uniparse "abc def^234") '(multiply (normalize-unit 'abc) (power (normalize-unit 'def) 234))) (check-expect (uniparse "abc+def/gh^234") '(add (normalize-unit 'abc) (divide (normalize-unit 'def) (power (normalize-unit 'gh) 234)))) ; tests with extra whitespace (check-expect (uniparse "abc ") '(normalize-unit 'abc)) (check-expect (uniparse " abc") '(normalize-unit 'abc)) (check-expect (uniparse "abc de") '(multiply (normalize-unit 'abc) (normalize-unit 'de))) (check-expect (uniparse "abc de") '(multiply (normalize-unit 'abc) (normalize-unit 'de))) (check-expect (uniparse "abc +de") '(add (normalize-unit 'abc) (normalize-unit 'de))) (check-expect (uniparse "abc+ de") '(add (normalize-unit 'abc) (normalize-unit 'de))) (check-expect (uniparse "abc -de") '(subtract (normalize-unit 'abc) (normalize-unit 'de))) (check-expect (uniparse "abc- de") '(subtract (normalize-unit 'abc) (normalize-unit 'de))) (check-expect (uniparse "(abc def/gh )") '(divide (multiply (normalize-unit 'abc) (normalize-unit 'def)) (normalize-unit 'gh))) (check-expect (uniparse "(abc def/ gh)") '(divide (multiply (normalize-unit 'abc) (normalize-unit 'def)) (normalize-unit 'gh))) (check-expect (uniparse "(abc def /gh)") '(divide (multiply (normalize-unit 'abc) (normalize-unit 'def)) (normalize-unit 'gh))) (check-expect (uniparse "( abc def g h i)") '(multiply (multiply (multiply (multiply (normalize-unit 'abc) (normalize-unit 'def)) (normalize-unit 'g)) (normalize-unit 'h)) (normalize-unit 'i))) (check-expect (uniparse "( (abc)(def))") '(multiply (normalize-unit 'abc) (normalize-unit 'def))) (check-expect (uniparse "( (abc) (def) )") '(multiply (normalize-unit 'abc) (normalize-unit 'def))) (check-expect (uniparse "((abc) def)") '(multiply (normalize-unit 'abc) (normalize-unit 'def))) (check-expect (uniparse "((abc) (def))") '(multiply (normalize-unit 'abc) (normalize-unit 'def))) (check-expect (uniparse "abc^ 234") '(power (normalize-unit 'abc) 234)) (check-expect (uniparse "abc ^234") '(power (normalize-unit 'abc) 234)) (check-expect (uniparse "abc ^ 234") '(power (normalize-unit 'abc) 234))