Skip to content
This repository was archived by the owner on Mar 23, 2023. It is now read-only.

Add pow builtin - #373

Open
aisk wants to merge 1 commit into
google:masterfrom
aisk:builtin-pow
Open

Add pow builtin#373
aisk wants to merge 1 commit into
google:masterfrom
aisk:builtin-pow

Conversation

@aisk

@aisk aisk commented Jul 30, 2017

Copy link
Copy Markdown
Contributor

No description provided.

@trotterdylan trotterdylan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the PR! Just a couple small suggestions.

Comment thread runtime/builtin_types.go Outdated
if raised := checkFunctionArgs(f, "pow", args, expectedTypes...); raised != nil {
return nil, raised
}
v := args[0]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you just call return Pow(f, args[0], args[1]) instead?

{f: "ord", args: wrapArgs("foo"), wantExc: mustCreateException(ValueErrorType, "ord() expected a character, but string of length 3 found")},
{f: "ord", args: wrapArgs(NewUnicode("волн")), wantExc: mustCreateException(ValueErrorType, "ord() expected a character, but string of length 4 found")},
{f: "ord", args: wrapArgs(1, 2, 3), wantExc: mustCreateException(TypeErrorType, "'ord' requires 1 arguments")},
{f: "pow", args: wrapArgs(1), wantExc: mustCreateException(TypeErrorType, "'pow' requires 2 arguments")},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would be nice to have a couple more test cases, e.g. a negative exponent and a complex number

@aisk

aisk commented Sep 7, 2017

Copy link
Copy Markdown
Contributor Author

@trotterdylan Ready for review!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

2 participants