Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(typeEvaluator): Support math functions #225

Merged
merged 1 commit into from
May 8, 2024
Merged

Conversation

sgulseth
Copy link
Member

@sgulseth sgulseth commented Apr 24, 2024

No description provided.

@sgulseth sgulseth requested a review from judofyr April 24, 2024 14:47
@sgulseth sgulseth changed the title fix(typeEvaluator): update hash group to capture start/end fix(typeEvaluator): Support math functions Apr 25, 2024
@sgulseth sgulseth force-pushed the feat/math-functions branch 7 times, most recently from 54b9959 to 330d15c Compare May 2, 2024 10:03
Copy link
Collaborator

@judofyr judofyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I found one problem with the implementation, but otherwise it looks good.

Can we also add tests like this for these?

diff --git i/test/typeEvaluateCompare.test.ts w/test/typeEvaluateCompare.test.ts
index d6f25e8..0c5b39b 100644
--- i/test/typeEvaluateCompare.test.ts
+++ w/test/typeEvaluateCompare.test.ts
@@ -2,6 +2,7 @@
 import t from 'tap'
 
 import {evaluate} from '../src/evaluator'
+import {namespaces} from '../src/evaluator/functions'
 import {operators} from '../src/evaluator/operators'
 import type {ExprNode, OpCall} from '../src/nodeTypes'
 import type {TypeNode} from '../src/typeEvaluator'
@@ -415,3 +416,16 @@ for (const op of ops) {
     })
   })
 }
+
+t.test('math::max', async (t) => {
+  subtestUnary({
+    t,
+    build: (param) => ({
+      type: 'FuncCall',
+      name: 'max',
+      namespace: 'math',
+      args: [param],
+      func: namespaces.math.max,
+    }),
+  })
+})

src/typeEvaluator/functions.ts Show resolved Hide resolved
@sgulseth
Copy link
Member Author

sgulseth commented May 3, 2024

Nice! I also caught a few more bugs because of some differences between avg and sum :D

@sgulseth sgulseth merged commit 531fe81 into main May 8, 2024
9 checks passed
@sgulseth sgulseth deleted the feat/math-functions branch May 8, 2024 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants