Skip to content

Commit

Permalink
refactor tests for math functions
Browse files Browse the repository at this point in the history
  • Loading branch information
itchyny committed Mar 3, 2024
1 parent 19f3fa7 commit 0a38bb1
Showing 1 changed file with 103 additions and 95 deletions.
198 changes: 103 additions & 95 deletions cli/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3950,7 +3950,7 @@
expected: |
false
- name: trigonometric functions
- name: sin, cos, tan functions
args:
- -c
- 'map(sin), map(cos), map(tan) | map(. * 1000000000 | floor / 1000000000)'
Expand All @@ -3960,7 +3960,7 @@
[1,0.540302305,-0.416146837]
[0,1.557407724,-2.185039864]
- name: inverse trigonometric functions
- name: asin, acos, atan functions
args:
- -c
- 'map(asin), map(acos), map(atan) | map(. * 1000000000 | floor / 1000000000)'
Expand All @@ -3970,7 +3970,7 @@
[1.570796326,0,null]
[0,0.785398163,1.107148717]
- name: hyperbolic functions
- name: sinh, cosh, tanh functions
args:
- -c
- 'map(sinh), map(cosh), map(tanh) | map(. * 1000000000 | floor / 1000000000)'
Expand All @@ -3980,7 +3980,7 @@
[1,1.543080634,3.762195691]
[0,0.761594155,0.96402758]
- name: inverse hyperbolic functions
- name: asinh, acosh, atanh functions
args:
- -c
- 'map(asinh), map(acosh), map(atanh) | map(. * 1000000000 | floor / 1000000000)'
Expand Down Expand Up @@ -4015,134 +4015,142 @@
args:
- -c
- 'map(sqrt), map(cbrt) | map(. * 1000000000 | floor / 1000000000)'
input: '[-8, -3.375, 0, 0.125, 1, 4, 8, 40.96, 64]'
input: '[-8, -3.375, 0, 0.125, 1, 4, 8, 9, 16.777216]'
expected: |
[null,null,0,0.35355339,1,2,2.828427124,6.4,8]
[-2,-1.5,0,0.5,1,1.587401051,2,3.447095504,4]
[null,null,0,0.35355339,1,2,2.828427124,3,4.096]
[-2,-1.5,0,0.5,1,1.587401051,2,2.080083823,2.56]
- name: significand function
args:
- -c
- '(range(10)|tan),nan | significand | . * 100000 | floor / 100000'
input: '0'
- 'map(significand)'
input: '[0, -0.5, 1, -1.5, 2, 10, 64, 100]'
expected: |
0
1.5574
-1.09252
-1.14038
1.15782
-1.69026
-1.16403
1.74289
-1.69993
-1.80927
null
[0,-1,1,-1.5,1,1.25,1,1.5625]
- name: exp, exp10, exp2, expm1, pow10 functions
args:
- -c
- '[range(.)] | map(exp),map(exp10),map(exp2),map(expm1),map(pow10) | map(. * 100000 | floor / 100000)'
input: '10'
- 'map(exp), map(exp10), map(exp2), map(expm1), map(pow10) | map(. * 1000000000 | floor / 1000000000)'
input: '[0, -0.5, 1, -1.5, 2, 10, 100, 300]'
expected: |
[1,2.71828,7.38905,20.08553,54.59815,148.41315,403.42879,1096.63315,2980.95798,8103.08392]
[1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000]
[1,2,4,8,16,32,64,128,256,512]
[0,1.71828,6.38905,19.08553,53.59815,147.41315,402.42879,1095.63315,2979.95798,8102.08392]
[1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000]
[1,0.606530659,2.718281828,0.22313016,7.389056098,22026.465794806,2.6881171418161356e+43,1.9424263952412558e+130]
[1,0.316227766,10,0.031622776,100,10000000000,1.0000000000000002e+100,1.7976931348623157e+308]
[1,0.707106781,2,0.35355339,4,1024,1.2676506002282294e+30,2.037035976334486e+90]
[0,-0.393469341,1.718281828,-0.77686984,6.389056098,22025.465794806,2.6881171418161356e+43,1.9424263952412558e+130]
[1,0.316227766,10,0.031622776,100,10000000000,1.0000000000000002e+100,1.7976931348623157e+308]
- name: frexp, modf function
args:
- -c
- '[range(.) | tan] | map(frexp),map(modf) | map(map(. * 100000 | floor / 100000))'
input: '10'
- 'map(frexp), map(modf)'
input: '[0, 0.25, -0.5, 1, -1.5, 2, 3.125]'
expected: |
[[0,0],[0.7787,1],[-0.54626,2],[-0.57019,-2],[0.57891,1],[-0.84513,2],[-0.58202,-1],[0.87144,0],[-0.84997,3],[-0.90464,-1]]
[[0,0],[0.5574,1],[-0.18504,-2],[-0.14255,-0],[0.15782,1],[-0.38052,-3],[-0.29101,-0],[0.87144,0],[-0.79972,-6],[-0.45232,-0]]
[[0,0],[0.5,-1],[-0.5,0],[0.5,1],[-0.75,1],[0.5,2],[0.78125,2]]
[[0,0],[0.25,0],[-0.5,-0],[0,1],[-0.5,-1],[0,2],[0.125,3]]
- name: log, log10, log1p, log2, logb functions
args:
- -c
- '[range(.) | tan] | map(log),map(log10),map(log1p),map(log2),map(logb) | map(. * 100000 | floor / 100000)'
input: '10'
- 'map(log), map(log10), map(log1p), map(log2), map(logb) | map(. * 1000000000 | floor / 1000000000)'
input: '[0, -0.5, 1, 1.5, 2, 10, 64, 100]'
expected: |
[-1.7976931348623157e+308,0.44302,null,null,0.14654,null,null,-0.1376,null,null]
[-1.7976931348623157e+308,0.1924,null,null,0.06364,null,null,-0.05976,null,null]
[0,0.93899,null,-0.15379,0.76909,null,-0.34391,0.62671,null,-0.60206]
[-1.7976931348623157e+308,0.63914,null,null,0.21141,null,null,-0.19852,null,null]
[-1.7976931348623157e+308,0,1,-3,0,1,-2,-1,2,-2]
[-1.7976931348623157e+308,null,0,0.405465108,0.69314718,2.302585092,4.158883083,4.605170185]
[-1.7976931348623157e+308,null,0,0.176091259,0.301029995,1,1.806179973,2]
[0,-0.693147181,0.69314718,0.916290731,1.098612288,2.397895272,4.174387269,4.615120516]
[-1.7976931348623157e+308,null,0,0.5849625,1,3.321928094,6,6.643856189]
[-1.7976931348623157e+308,-1,0,0,1,3,6,6]
- name: gamma, tgamma, lgamma functions
args:
- -c
- '[range(.) | tan] | map(gamma),map(tgamma),map(lgamma) | map(. * 100000 | floor / 100000)'
input: '10'
- 'map(gamma), map(tgamma), map(lgamma) | map(. * 1000000000 | floor / 1000000000)'
input: '[0, -0.5, 1, -1.5, 2, 10]'
expected: |
[1.7976931348623157e+308,0.88943,-2.39565,-7.75522,0.93049,0.34209,-4.41241,1.09278,-0.00159,-3.58744]
[1.7976931348623157e+308,0.88943,-2.39565,-7.75522,0.93049,0.34209,-4.41241,1.09278,-0.00159,-3.58744]
[1.7976931348623157e+308,-0.11718,0.87365,2.04836,-0.07204,-1.07268,1.48441,0.08872,-6.44927,1.27743]
[1.7976931348623157e+308,-3.544907702,1,2.363271801,1,362880]
[1.7976931348623157e+308,-3.544907702,1,2.363271801,1,362880]
[1.7976931348623157e+308,1.265512123,0,0.860047015,0,12.80182748]
- name: erf, erfc, j0, j1, y0, y1 functions
args:
- -c
- '[range(.) | tan] | map(erf),map(erfc),map(j0),map(j1),map(y0),map(y1) | map(. * 100000 | floor / 100000)'
input: '10'
- 'map(erf), map(erfc), map(j0), map(j1), map(y0), map(y1) | map(. * 1000000000 | floor / 1000000000)'
input: '[0, -0.5, 1, -1.5, 2, 10]'
expected: |
[0,0.97237,-0.998,-0.15977,0.89845,-1,-0.31933,0.7822,-1,-0.47762]
[1,0.02762,1.99799,1.15976,0.10154,1.99999,1.31932,0.21779,2,1.47761]
[1,0.47958,0.11869,0.99492,0.69191,-0.36073,0.97894,0.81896,0.29307,0.9495]
[0,0.56529,-0.55806,-0.0711,0.48717,-0.18735,-0.14397,0.39565,0.0653,-0.22043]
[-1.7976931348623157e+308,0.40504,null,null,0.20121,null,null,-0.01971,null,null]
[-1.7976931348623157e+308,-0.37491,null,null,-0.653,null,null,-0.90154,null,null]
- name: atan2/2, copysign/2, drem/2, fdim/2, fmax/2, fmin/2, fmod/2, hypot/2, jn/2, ldexp/2, nextafter/2, nexttoward/2, remainder/2, scalb/2, scalbln/2, pow/2, yn/2 functions
args:
- -c
- '[range(-.;.)] |
[atan2(.[]; .[])],
[copysign(.[]; .[])],
[drem(.[]; .[])],
[fdim(.[]; .[])],
[fmax(.[]; .[])],
[fmin(.[]; .[])],
[fmod(.[]; .[])],
[hypot(.[]; .[])],
[jn(.[]; .[])],
[ldexp(.[]; .[])],
[nextafter(.[]; .[])],
[nexttoward(.[]; .[])],
[remainder(.[]; .[])],
[scalb(.[]; .[])],
[scalbln(.[]; .[])],
[pow(.[]; .[])],
[yn(.[]; .[])]
| map(. * 10000 | round | . / 10000)'
input: '3'
[0,-0.520499878,0.842700792,-0.966105147,0.995322265,1]
[1,1.520499877,0.157299207,1.966105146,0.004677734,0]
[1,0.938469807,0.765197686,0.511827671,0.223890779,-0.245935765]
[0,-0.242268458,0.440050585,-0.557936508,0.576724807,0.043472746]
[-1.7976931348623157e+308,null,0.088256964,null,0.510375672,0.055671167]
[-1.7976931348623157e+308,null,-0.781212822,null,-0.107032432,0.249015424]
- name: fdim/2, fmax/2, fmin/2 functions
args:
- -c
- '[fdim(0.25,0.625; 0.125,0.375)], [fmax(0.1,0.3; 0.2,0.4)], [fmin(0.1,0.3; 0.2,0.4)]'
input: 'null'
expected: |
[0.125,0.5,0,0.25]
[0.2,0.3,0.4,0.4]
[0.1,0.2,0.1,0.3]
- name: copysign/2, drem/2, fmod/2, remainder/2 functions
args:
- -c
- '[copysign(0,0.5,-1.5; 0,1,-3.5)], [drem(0.5,-0.75,1.125; 0.5,-0.25)],
[fmod(0.5,-0.75,1.125; 0.5,-0.25)], [remainder(0.5,-0.75,1.125; 0.5,-0.25)]'
input: 'null'
expected: |
[-2.3562,-2.5536,-2.8198,3.1416,2.8198,2.5536,-2.1588,-2.3562,-2.6779,3.1416,2.6779,2.3562,-1.8925,-2.0344,-2.3562,3.1416,2.3562,2.0344,-1.5708,-1.5708,-1.5708,0,1.5708,1.5708,-1.249,-1.1071,-0.7854,0,0.7854,1.1071,-0.9828,-0.7854,-0.4636,0,0.4636,0.7854]
[-3,-2,-1,-0,-1,-2,-3,-2,-1,-0,-1,-2,-3,-2,-1,-0,-1,-2,3,2,1,0,1,2,3,2,1,0,1,2,3,2,1,0,1,2]
[-0,1,-1,0,1,-1,1,-0,-1,0,1,0,-0,-0,-0,0,0,0,null,null,null,null,null,null,-0,-0,-0,0,0,0,1,-0,-1,0,1,0]
[0,1,2,3,4,5,0,0,1,2,3,4,0,0,0,1,2,3,0,0,0,0,1,2,0,0,0,0,0,1,0,0,0,0,0,0]
[-3,-2,-1,0,1,2,-2,-2,-1,0,1,2,-1,-1,-1,0,1,2,0,0,0,0,1,2,1,1,1,1,1,2,2,2,2,2,2,2]
[-3,-3,-3,-3,-3,-3,-3,-2,-2,-2,-2,-2,-3,-2,-1,-1,-1,-1,-3,-2,-1,0,0,0,-3,-2,-1,0,1,1,-3,-2,-1,0,1,2]
[-0,-2,-1,0,1,2,-1,-0,-1,0,1,0,-0,-0,-0,0,0,0,null,null,null,null,null,null,-0,-0,-0,0,0,0,-1,-0,-1,0,1,0]
[4.2426,3.6056,3.1623,3,3.1623,3.6056,3.6056,2.8284,2.2361,2,2.2361,2.8284,3.1623,2.2361,1.4142,1,1.4142,2.2361,3,2,1,0,1,2,3.1623,2.2361,1.4142,1,1.4142,2.2361,3.6056,2.8284,2.2361,2,2.2361,2.8284]
[0.3091,0.4861,0.3391,-0.2601,-0.3391,0.4861,0.1289,0.3528,0.5767,0.2239,-0.5767,0.3528,0.0196,0.1149,0.4401,0.7652,-0.4401,0.1149,0,0,0,1,0,0,-0.0196,0.1149,-0.4401,0.7652,0.4401,0.1149,-0.1289,0.3528,-0.5767,0.2239,0.5767,0.3528]
[-0.375,-0.25,-0.125,0,0.125,0.25,-0.75,-0.5,-0.25,0,0.25,0.5,-1.5,-1,-0.5,0,0.5,1,-3,-2,-1,0,1,2,-6,-4,-2,0,2,4,-12,-8,-4,0,4,8]
[-3,-2,-1,-0,1,2,-3,-2,-1,-0,1,2,-3,-2,-1,-0,1,2,-3,-2,-1,0,1,2,-3,-2,-1,0,1,2,-3,-2,-1,0,1,2]
[-3,-2,-1,-0,1,2,-3,-2,-1,-0,1,2,-3,-2,-1,-0,1,2,-3,-2,-1,0,1,2,-3,-2,-1,0,1,2,-3,-2,-1,0,1,2]
[-0,1,-1,0,1,-1,1,-0,-1,0,1,0,-0,-0,-0,0,0,0,null,null,null,null,null,null,-0,-0,-0,0,0,0,1,-0,-1,0,1,0]
[-0.375,-0.25,-0.125,0,0.125,0.25,-0.75,-0.5,-0.25,0,0.25,0.5,-1.5,-1,-0.5,0,0.5,1,-3,-2,-1,0,1,2,-6,-4,-2,0,2,4,-12,-8,-4,0,4,8]
[-0.375,-0.25,-0.125,0,0.125,0.25,-0.75,-0.5,-0.25,0,0.25,0.5,-1.5,-1,-0.5,0,0.5,1,-3,-2,-1,0,1,2,-6,-4,-2,0,2,4,-12,-8,-4,0,4,8]
[-0.037,-0.125,-1,1.7976931348623157e+308,1,0.125,0.1111,0.25,1,1.7976931348623157e+308,1,0.25,-0.3333,-0.5,-1,1.7976931348623157e+308,1,0.5,1,1,1,1,1,1,-3,-2,-1,0,1,2,9,4,1,0,1,4]
[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1.7976931348623157e+308,-1.7976931348623157e+308,1.7976931348623157e+308,-1.7976931348623157e+308,-1.7976931348623157e+308,-1.7976931348623157e+308,5.8215,-1.6507,0.7812,0.0883,-0.7812,-1.6507,1.1278,-0.6174,0.107,0.5104,-0.107,-0.6174]
[0,0.5,1.5,0,0.5,1.5,-0,-0.5,-1.5]
[0,0.25,0.125,0,-0,0.125]
[0,-0.25,0.125,0,-0,0.125]
[0,0.25,0.125,0,-0,0.125]
- name: nextafter/2, nexttoward/2 functions
args:
- -c
- '[nextafter(0,0.5,-0.75; 0.5,-0.25)], [nexttoward(0,0.5,-0.75; 0.5,-0.25)]'
input: 'null'
expected: |
[5e-324,0.5,-0.7499999999999999,-5e-324,0.49999999999999994,-0.7499999999999999]
[5e-324,0.5,-0.7499999999999999,-5e-324,0.49999999999999994,-0.7499999999999999]
- name: atan2/2, hypot/2 functions
args:
- -c
- '[atan2(0,1; 0,1,-3)], [hypot(0,-3.75,12; 0,5,-16)]'
input: 'null'
expected: |
[0,1.5707963267948966,0,0.7853981633974483,3.141592653589793,2.819842099193151]
[0,3.75,12,5,6.25,13,16,16.433578429544795,20]
- name: ldexp/2, scalb/2, scalbln/2 functions
args:
- -c
- '[ldexp(0,0.5,2; 0,0.5,-2,3,10)], [scalb(0,0.5,2; 0,0.5,-2,3,10)], [scalbln(0,0.5,2; 0,0.5,-2,3,10)]'
input: 'null'
expected: |
[0,0.5,2,0,0.5,2,0,0.125,0.5,0,4,16,0,512,2048]
[0,0.5,2,0,0.5,2,0,0.125,0.5,0,4,16,0,512,2048]
[0,0.5,2,0,0.5,2,0,0.125,0.5,0,4,16,0,512,2048]
- name: jn/2, pow/2, yn/2 functions
args:
- -c
- '[jn(0,0.5,2; 0,0.5,-2,3,10)], [pow(0,0.5,2; 0,0.5,-2,3,10)], [yn(0,0.5,2; 0.5,-2,3,10)] | map(. * 1000000000 | floor / 1000000000)'
input: 'null'
expected: |
[1,1,0,0.938469807,0.938469807,0.030604023,0.223890779,0.223890779,0.352834028,-0.260051955,-0.260051955,0.48609126,-0.245935765,-0.245935765,0.254630313]
[1,1,1,0,0.707106781,1.414213562,1.7976931348623157e+308,4,0.25,0,0.125,8,0,0.000976562,1024]
[-0.444518734,-0.444518734,-5.441370838,null,null,null,0.37685001,0.37685001,-0.160400394,0.055671167,0.055671167,-0.005868083]
- name: fma/3 function
args:
- -c
- '[range(.) | . * 2 | sin] | [fma(.[]; .[]; .[])] | map(. * 100000 | floor / 100000)'
input: '3'
- '[fma(1.5,2.5; 3.5,4.5; 5.25,6.75)]'
input: 'null'
expected: |
[0,0,0,0,0.82682,-0.68816,0,-0.68816,0.57275,0.90929,0.90929,0.90929,0.90929,1.73611,0.22113,0.90929,0.22113,1.48204,-0.75681,-0.75681,-0.75681,-0.75681,0.07001,-1.44497,-0.75681,-1.44497,-0.18406]
[10.5,14,12,16.5,12,15.5,13.5,18]
- name: infinite function
args:
Expand Down

0 comments on commit 0a38bb1

Please sign in to comment.