Title: [282402] trunk/LayoutTests/imported/w3c

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (282401 => 282402)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-09-14 19:31:03 UTC (rev 282401)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-09-14 19:53:45 UTC (rev 282402)
@@ -1,3 +1,14 @@
+2021-09-14  Nikos Mouchtaris  <[email protected]>
+
+        Add wpts for sin,cos,tan
+        https://bugs.webkit.org/show_bug.cgi?id=230129
+
+        Reviewed by Simon Fraser.
+
+        * web-platform-tests/css/support/numeric-testcommon.js:
+        (test_math_used):
+        Added helper function for testing approximate equals.
+
 2021-09-14  Myles C. Maxfield  <[email protected]>
 
         Implement text-decoration-skip-ink

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/sin-cos-tan-computed-expected.txt (0 => 282402)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/sin-cos-tan-computed-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/sin-cos-tan-computed-expected.txt	2021-09-14 19:53:45 UTC (rev 282402)
@@ -0,0 +1,19 @@
+
+PASS cos(0) should be used-value-equivalent to 1
+PASS sin(0) should be used-value-equivalent to 0
+PASS tan(0) should be used-value-equivalent to 0
+PASS calc(sin(pi/2 - pi/2) ) should be used-value-equivalent to 0
+PASS calc(cos(pi - 3.14159265358979323846) ) should be used-value-equivalent to 1
+PASS calc(cos(e - 2.7182818284590452354) ) should be used-value-equivalent to 1
+PASS calc(sin(30deg + 1.0471967rad ) ) should be used-value-equivalent to 1
+PASS calc(cos(30deg - 0.523599rad ) ) should be used-value-equivalent to 1
+PASS calc(sin(3.14159 / 2 + 1 - 1) ) should be used-value-equivalent to 1
+PASS calc(sin(100grad) ) should be used-value-equivalent to 1
+PASS calc(cos(0 / 2 + 1 - 1) ) should be used-value-equivalent to 1
+PASS calc(tan(30deg + 0.261799rad ) ) should be used-value-equivalent to 1
+PASS calc(tan(0.7853975rad ) ) should be used-value-equivalent to 1
+PASS calc(tan(3.14159 / 4 + 1 - 1) ) should be used-value-equivalent to 1
+PASS calc(sin(0.25turn) ) should be used-value-equivalent to 1
+PASS calc(cos(sin(cos(pi) + 1))) should be used-value-equivalent to 1
+PASS calc(sin(tan(pi/4)*pi/2) ) should be used-value-equivalent to 1
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/sin-cos-tan-computed.html (0 => 282402)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/sin-cos-tan-computed.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/sin-cos-tan-computed.html	2021-09-14 19:53:45 UTC (rev 282402)
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<link rel="help" href=""
+<link rel="help" href=""
+<link rel="help" href=""
+<link rel="author" title="Apple Inc">
+<script src=""
+<script src=""
+<script src=""
+<div id="target"></div>
+<script>
+// Simple tests
+test_math_used('cos(0)', '1', {type:'number'});
+test_math_used('sin(0)', '0', {type:'number'});
+test_math_used('tan(0)', '0', {type:'number'});
+
+// Test pi
+test_math_used('calc(sin(pi/2 - pi/2) )', '0', {type:'number', approx:0.1});
+test_math_used('calc(cos(pi - 3.14159265358979323846) )', '1', {type:'number', approx:0.1});
+
+//Test e
+test_math_used('calc(cos(e - 2.7182818284590452354) )', '1', {type:'number', approx:0.1});
+
+//Test units
+test_math_used('calc(sin(30deg + 1.0471967rad ) )', '1', {type:'number', approx:0.1});
+test_math_used('calc(cos(30deg - 0.523599rad ) )', '1'), {type:'number', approx:0.1};
+test_math_used('calc(sin(3.14159 / 2 + 1 - 1) )', '1', {type:'number', approx:0.1});
+test_math_used('calc(sin(100grad) )', '1', {type:'number', approx:0.1});
+test_math_used('calc(cos(0 / 2 + 1 - 1) )', '1', {type:'number', approx:0.1});
+test_math_used('calc(tan(30deg + 0.261799rad ) )', '1', {type:'number', approx:0.1});
+test_math_used('calc(tan(0.7853975rad ) )', '1', {type:'number', approx:0.1});
+test_math_used('calc(tan(3.14159 / 4 + 1 - 1) )', '1', {type:'number', approx:0.1});
+test_math_used('calc(sin(0.25turn) )', '1', {type:'number', approx:0.1});
+
+//Test nesting
+test_math_used('calc(cos(sin(cos(pi) + 1)))', '1', {type:'number', approx:0.1});
+test_math_used('calc(sin(tan(pi/4)*pi/2) )', '1', {type:'number', approx:0.1});
+</script>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/sin-cos-tan-invalid-expected.txt (0 => 282402)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/sin-cos-tan-invalid-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/sin-cos-tan-invalid-expected.txt	2021-09-14 19:53:45 UTC (rev 282402)
@@ -0,0 +1,44 @@
+
+PASS e.style['transform'] = "rotate(sin())" should not set the property value
+PASS e.style['transform'] = "rotate(sin( ))" should not set the property value
+PASS e.style['transform'] = "rotate(sin(,))" should not set the property value
+PASS e.style['transform'] = "rotate(sin(1dag))" should not set the property value
+PASS e.style['transform'] = "rotate(sin(1deg, ))" should not set the property value
+PASS e.style['transform'] = "rotate(sin(, 1deg))" should not set the property value
+PASS e.style['transform'] = "rotate(sin(1deg + ))" should not set the property value
+PASS e.style['transform'] = "rotate(sin(1deg - ))" should not set the property value
+PASS e.style['transform'] = "rotate(sin(1deg * ))" should not set the property value
+PASS e.style['transform'] = "rotate(sin(1deg / ))" should not set the property value
+PASS e.style['transform'] = "rotate(sin(1deg 2deg))" should not set the property value
+PASS e.style['transform'] = "rotate(sin(1deg, , 2deg))" should not set the property value
+PASS e.style['transform'] = "rotate(cos())" should not set the property value
+PASS e.style['transform'] = "rotate(cos( ))" should not set the property value
+PASS e.style['transform'] = "rotate(cos(,))" should not set the property value
+PASS e.style['transform'] = "rotate(cos(1dag))" should not set the property value
+PASS e.style['transform'] = "rotate(cos(1deg, ))" should not set the property value
+PASS e.style['transform'] = "rotate(cos(, 1deg))" should not set the property value
+PASS e.style['transform'] = "rotate(cos(1deg + ))" should not set the property value
+PASS e.style['transform'] = "rotate(cos(1deg - ))" should not set the property value
+PASS e.style['transform'] = "rotate(cos(1deg * ))" should not set the property value
+PASS e.style['transform'] = "rotate(cos(1deg / ))" should not set the property value
+PASS e.style['transform'] = "rotate(cos(1deg 2deg))" should not set the property value
+PASS e.style['transform'] = "rotate(cos(1deg, , 2deg))" should not set the property value
+PASS e.style['transform'] = "rotate(tan())" should not set the property value
+PASS e.style['transform'] = "rotate(tan( ))" should not set the property value
+PASS e.style['transform'] = "rotate(tan(,))" should not set the property value
+PASS e.style['transform'] = "rotate(tan(1dag))" should not set the property value
+PASS e.style['transform'] = "rotate(tan(1deg, ))" should not set the property value
+PASS e.style['transform'] = "rotate(tan(, 1deg))" should not set the property value
+PASS e.style['transform'] = "rotate(tan(1deg + ))" should not set the property value
+PASS e.style['transform'] = "rotate(tan(1deg - ))" should not set the property value
+PASS e.style['transform'] = "rotate(tan(1deg * ))" should not set the property value
+PASS e.style['transform'] = "rotate(tan(1deg / ))" should not set the property value
+PASS e.style['transform'] = "rotate(tan(1deg 2deg))" should not set the property value
+PASS e.style['transform'] = "rotate(tan(1deg, , 2deg))" should not set the property value
+PASS e.style['transform'] = "rotate(sin(90px))" should not set the property value
+PASS e.style['transform'] = "rotate(sin(30deg + 1.0471967rad, 0))" should not set the property value
+PASS e.style['transform'] = "rotate(cos( 0 ,))" should not set the property value
+PASS e.style['transform'] = "rotate(cos( () 30deg - 0.523599rad ))" should not set the property value
+PASS e.style['transform'] = "rotate(tan(45deg ))" should not set the property value
+PASS e.style['transform'] = "rotate(tan(30deg, + 0.261799rad))" should not set the property value
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/sin-cos-tan-invalid.html (0 => 282402)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/sin-cos-tan-invalid.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/sin-cos-tan-invalid.html	2021-09-14 19:53:45 UTC (rev 282402)
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<link rel="help" href=""
+<link rel="help" href=""
+<link rel="help" href=""
+<link rel="author" title="Apple Inc">
+<script src=""
+<script src=""
+<script src=""
+<script>
+function test_invalid_angle(value) {
+  test_invalid_value('transform', `rotate(${value})`);
+}
+
+// Syntax checking
+test_invalid_angle('sin()');
+test_invalid_angle('sin( )');
+test_invalid_angle('sin(,)');
+test_invalid_angle('sin(1dag)');
+test_invalid_angle('sin(1deg, )');
+test_invalid_angle('sin(, 1deg)');
+test_invalid_angle('sin(1deg + )');
+test_invalid_angle('sin(1deg - )');
+test_invalid_angle('sin(1deg * )');
+test_invalid_angle('sin(1deg / )');
+test_invalid_angle('sin(1deg 2deg)');
+test_invalid_angle('sin(1deg, , 2deg)');
+test_invalid_angle('cos()');
+test_invalid_angle('cos( )');
+test_invalid_angle('cos(,)');
+test_invalid_angle('cos(1dag)');
+test_invalid_angle('cos(1deg, )');
+test_invalid_angle('cos(, 1deg)');
+test_invalid_angle('cos(1deg + )');
+test_invalid_angle('cos(1deg - )');
+test_invalid_angle('cos(1deg * )');
+test_invalid_angle('cos(1deg / )');
+test_invalid_angle('cos(1deg 2deg)');
+test_invalid_angle('cos(1deg, , 2deg)');
+test_invalid_angle('tan()');
+test_invalid_angle('tan( )');
+test_invalid_angle('tan(,)');
+test_invalid_angle('tan(1dag)');
+test_invalid_angle('tan(1deg, )');
+test_invalid_angle('tan(, 1deg)');
+test_invalid_angle('tan(1deg + )');
+test_invalid_angle('tan(1deg - )');
+test_invalid_angle('tan(1deg * )');
+test_invalid_angle('tan(1deg / )');
+test_invalid_angle('tan(1deg 2deg)');
+test_invalid_angle('tan(1deg, , 2deg)');
+test_invalid_angle('sin(90px)');
+test_invalid_angle('sin(30deg + 1.0471967rad, 0)');
+test_invalid_angle('cos( 0 ,)');
+test_invalid_angle('cos( () 30deg - 0.523599rad )');
+test_invalid_angle('tan(45deg )');
+test_invalid_angle('tan(30deg, + 0.261799rad)');
+</script>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/sin-cos-tan-serialize-expected.txt (0 => 282402)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/sin-cos-tan-serialize-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/sin-cos-tan-serialize-expected.txt	2021-09-14 19:53:45 UTC (rev 282402)
@@ -0,0 +1,30 @@
+
+FAIL 'cos(0)' as a specified value should serialize as 'calc(1)'. assert_equals: 'cos(0)' and 'calc(1)' should serialize the same in specified values. expected "calc(1)" but got "cos(0)"
+FAIL 'scale(cos(0))' as a specified value should serialize as 'scale(calc(1))'. assert_equals: 'scale(cos(0))' and 'scale(calc(1))' should serialize the same in specified values. expected "scale(calc(1))" but got "scale(cos(0))"
+PASS 'cos(0)' as a computed value should serialize as '1'.
+PASS 'scale(cos(0))' as a computed value should serialize as 'matrix(1, 0, 0, 1, 0, 0)'.
+FAIL 'sin(0)' as a specified value should serialize as 'calc(0)'. assert_equals: 'sin(0)' and 'calc(0)' should serialize the same in specified values. expected "calc(0)" but got "sin(0)"
+FAIL 'scale(sin(0))' as a specified value should serialize as 'scale(calc(0))'. assert_equals: 'scale(sin(0))' and 'scale(calc(0))' should serialize the same in specified values. expected "scale(calc(0))" but got "scale(sin(0))"
+PASS 'sin(0)' as a computed value should serialize as '0'.
+PASS 'scale(sin(0))' as a computed value should serialize as 'matrix(0, 0, 0, 0, 0, 0)'.
+FAIL 'tan(0)' as a specified value should serialize as 'calc(0)'. assert_equals: 'tan(0)' and 'calc(0)' should serialize the same in specified values. expected "calc(0)" but got "tan(0)"
+FAIL 'scale(tan(0))' as a specified value should serialize as 'scale(calc(0))'. assert_equals: 'scale(tan(0))' and 'scale(calc(0))' should serialize the same in specified values. expected "scale(calc(0))" but got "scale(tan(0))"
+PASS 'tan(0)' as a computed value should serialize as '0'.
+PASS 'scale(tan(0))' as a computed value should serialize as 'matrix(0, 0, 0, 0, 0, 0)'.
+PASS 'calc(sin(0) + cos(0) + tan(0))' as a specified value should serialize as 'calc(1)'.
+PASS 'scale(calc(sin(0) + cos(0) + tan(0)))' as a specified value should serialize as 'scale(calc(1))'.
+PASS 'calc(sin(0) + cos(0) + tan(0))' as a computed value should serialize as '1'.
+PASS 'scale(calc(sin(0) + cos(0) + tan(0)))' as a computed value should serialize as 'matrix(1, 0, 0, 1, 0, 0)'.
+PASS 'calc(sin(0) + 0.5)' as a specified value should serialize as 'calc(0.5)'.
+PASS 'scale(calc(sin(0) + 0.5))' as a specified value should serialize as 'scale(calc(0.5))'.
+PASS 'calc(sin(0) + 0.5)' as a computed value should serialize as '0.5'.
+PASS 'scale(calc(sin(0) + 0.5))' as a computed value should serialize as 'matrix(0.5, 0, 0, 0.5, 0, 0)'.
+PASS 'calc(cos(0) + 0.5)' as a specified value should serialize as 'calc(1.5)'.
+PASS 'scale(calc(cos(0) + 0.5))' as a specified value should serialize as 'scale(calc(1.5))'.
+FAIL 'calc(cos(0) + 0.5)' as a computed value should serialize as '1.5'. assert_equals: '1.5' should round-trip exactly in computed values. expected "1.5" but got "1"
+PASS 'scale(calc(cos(0) + 0.5))' as a computed value should serialize as 'matrix(1.5, 0, 0, 1.5, 0, 0)'.
+PASS 'calc(tan(0) + 0.5)' as a specified value should serialize as 'calc(0.5)'.
+PASS 'scale(calc(tan(0) + 0.5))' as a specified value should serialize as 'scale(calc(0.5))'.
+PASS 'calc(tan(0) + 0.5)' as a computed value should serialize as '0.5'.
+PASS 'scale(calc(tan(0) + 0.5))' as a computed value should serialize as 'matrix(0.5, 0, 0, 0.5, 0, 0)'.
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/sin-cos-tan-serialize.html (0 => 282402)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/sin-cos-tan-serialize.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/sin-cos-tan-serialize.html	2021-09-14 19:53:45 UTC (rev 282402)
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<link rel="help" href=""
+<link rel="help" href=""
+<link rel="help" href=""
+<link rel="author" title="Apple Inc">
+<script src=""
+<script src=""
+<script src=""
+<div id=target></div>
+<script>
+function test_serialization(t,s,c) {
+    test_specified_serialization('opacity', t, s);
+    test_specified_serialization('transform', `scale(${t})`, `scale(calc(${c}))`);
+    test_computed_serialization('opacity', t, c);
+    test_computed_serialization('transform', `scale(${t})`, `matrix(${c}, 0, 0, ${c}, 0, 0)`);
+}
+
+test_serialization(
+    'cos(0)',
+    'calc(1)',
+    '1');
+test_serialization(
+    'sin(0)',
+    'calc(0)',
+    '0');
+test_serialization(
+    'tan(0)',
+    'calc(0)',
+    '0');
+
+test_serialization(
+    'calc(sin(0) + cos(0) + tan(0))',
+    'calc(1)',
+    '1');
+
+test_serialization(
+    'calc(sin(0) + 0.5)',
+    'calc(0.5)',
+    '0.5');
+test_serialization(
+    'calc(cos(0) + 0.5)',
+    'calc(1.5)',
+    '1.5');
+test_serialization(
+    'calc(tan(0) + 0.5)',
+    'calc(0.5)',
+    '0.5');
+</script>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/support/numeric-testcommon.js (282401 => 282402)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/support/numeric-testcommon.js	2021-09-14 19:31:03 UTC (rev 282401)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/support/numeric-testcommon.js	2021-09-14 19:53:45 UTC (rev 282402)
@@ -42,7 +42,7 @@
 
 
 
-function test_math_used(testString, expectedString, {msg, msgExtra, type, prop, prefix, suffix, extraStyle={}}={}) {
+function test_math_used(testString, expectedString, {approx, msg, msgExtra, type, prop, prefix, suffix, extraStyle={}}={}) {
     if(type === undefined) type = "length";
     if(!prop) {
         switch(type) {
@@ -57,10 +57,10 @@
         }
 
     }
-    _test_math({stage:'used', testString, expectedString, type, msg, msgExtra, prop, prefix, suffix, extraStyle});
+    _test_math({stage:'used', testString, expectedString, type, approx, msg, msgExtra, prop, prefix, suffix, extraStyle});
 }
 
-function test_math_computed(testString, expectedString, {msg, msgExtra, type, prop, prefix, suffix, extraStyle={}}={}) {
+function test_math_computed(testString, expectedString, {approx, msg, msgExtra, type, prop, prefix, suffix, extraStyle={}}={}) {
     if(type === undefined) type = "length";
     if(!prop) {
         switch(type) {
@@ -75,10 +75,10 @@
         }
 
     }
-    _test_math({stage:'computed', testString, expectedString, type, msg, msgExtra, prop, prefix, suffix, extraStyle});
+    _test_math({stage:'computed', testString, expectedString, type, approx, msg, msgExtra, prop, prefix, suffix, extraStyle});
 }
 
-function test_math_specified(testString, expectedString, {msg, msgExtra, type, prop, prefix, suffix, extraStyle={}}={}) {
+function test_math_specified(testString, expectedString, {approx, msg, msgExtra, type, prop, prefix, suffix, extraStyle={}}={}) {
     if(type === undefined) type = "length";
     const stage = "specified";
     if(!prop) {
@@ -152,7 +152,7 @@
 }
 
 
-function _test_math({stage, testEl, testString, expectedString, type, msg, msgExtra, prop, prefix, suffix, extraStyle}={}) {
+function _test_math({stage, testEl, testString, expectedString, type, approx, msg, msgExtra, prop, prefix, suffix, extraStyle}={}) {
     // Find the test element
     if(!testEl) testEl = document.getElementById('target');
     if(testEl == null) throw "Couldn't find #target element to run tests on.";
@@ -184,6 +184,12 @@
         testEl.style[prop] = e;
         const expectedValue = getComputedStyle(testEl)[prop];
         assert_not_equals(expectedValue, '', `${expectedString} isn't valid in '${prop}'; got the default value instead.`)
-        assert_equals(usedValue, expectedValue, `${testString} and ${expectedString} serialize to the same thing in ${stage} values.`);
+        if(approx && type == "number"){
+            let parsedUsed = usedValue.split('(')[1].split(')')[0].split(',').map(parseFloat);
+            let parsedExpected = expectedValue.split('(')[1].split(')')[0].split(',').map(parseFloat);
+            assert_array_approx_equals(parsedUsed, parsedExpected, approx, `${testString} and ${expectedString} ${approx} serialize to the same thing in ${stage} values.`);
+        } else {
+            assert_equals(usedValue, expectedValue, `${testString} and ${expectedString} serialize to the same thing in ${stage} values.`);
+        }
     }, msg || `${testString} should be ${stage}-value-equivalent to ${expectedString}`);
 }
\ No newline at end of file
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to