Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: src/animator/SkScriptTokenizer.cpp

Issue 22732004: Fix build with SK_SUPPORT_UNITTEST on (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/animator/SkScript.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SkScript2.h" 8 #include "SkScript2.h"
9 #include "SkData.h" 9 #include "SkData.h"
10 #include "SkFloatingPoint.h" 10 #include "SkFloatingPoint.h"
(...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 testInt(0&&1?2:3) 1472 testInt(0&&1?2:3)
1473 , { "123.5", SkOperand2::kScalar, 0, SkIntToScalar(123) + SK_Scalar1/2, N ULL } 1473 , { "123.5", SkOperand2::kScalar, 0, SkIntToScalar(123) + SK_Scalar1/2, N ULL }
1474 }; 1474 };
1475 1475
1476 #define SkScriptNAnswer_testCount SK_ARRAY_COUNT(scriptTests) 1476 #define SkScriptNAnswer_testCount SK_ARRAY_COUNT(scriptTests)
1477 #endif // SK_SUPPORT_UNITTEST 1477 #endif // SK_SUPPORT_UNITTEST
1478 1478
1479 void SkScriptEngine2::UnitTest() { 1479 void SkScriptEngine2::UnitTest() {
1480 #if defined(SK_SUPPORT_UNITTEST) 1480 #if defined(SK_SUPPORT_UNITTEST)
1481 ValidateDecompileTable(); 1481 ValidateDecompileTable();
1482 for (int index = 0; index < SkScriptNAnswer_testCount; index++) { 1482 for (size_t index = 0; index < SkScriptNAnswer_testCount; index++) {
1483 SkScriptEngine2 engine(scriptTests[index].fType); 1483 SkScriptEngine2 engine(scriptTests[index].fType);
1484 SkScriptValue2 value; 1484 SkScriptValue2 value;
1485 const char* script = scriptTests[index].fScript; 1485 const char* script = scriptTests[index].fScript;
1486 const char* scriptPtr = script; 1486 const char* scriptPtr = script;
1487 SkASSERT(engine.evaluateScript(&scriptPtr, &value) == true); 1487 SkASSERT(engine.evaluateScript(&scriptPtr, &value) == true);
1488 SkASSERT(value.fType == scriptTests[index].fType); 1488 SkASSERT(value.fType == scriptTests[index].fType);
1489 SkScalar error; 1489 SkScalar error;
1490 switch (value.fType) { 1490 switch (value.fType) {
1491 case SkOperand2::kS32: 1491 case SkOperand2::kS32:
1492 if (value.fOperand.fS32 != scriptTests[index].fIntAnswer) 1492 if (value.fOperand.fS32 != scriptTests[index].fIntAnswer)
1493 SkDEBUGF(("script '%s' == value %d != expected answer %d\n", script, value.fOperand.fS32, scriptTests[index].fIntAnswer)); 1493 SkDEBUGF(("script '%s' == value %d != expected answer %d\n", script, value.fOperand.fS32, scriptTests[index].fIntAnswer));
1494 SkASSERT(value.fOperand.fS32 == scriptTests[index].fIntAnswer); 1494 SkASSERT(value.fOperand.fS32 == scriptTests[index].fIntAnswer);
1495 break; 1495 break;
1496 case SkOperand2::kScalar: 1496 case SkOperand2::kScalar:
1497 error = SkScalarAbs(value.fOperand.fScalar - scriptTests[index]. fScalarAnswer); 1497 error = SkScalarAbs(value.fOperand.fScalar - scriptTests[index]. fScalarAnswer);
1498 if (error >= SK_Scalar1 / 10000) 1498 if (error >= SK_Scalar1 / 10000)
1499 SkDEBUGF(("script '%s' == value %g != expected answer %g\n", script, value.fOperand.fScalar / (1.0f * SK_Scalar1), scriptTests[index].fScala rAnswer / (1.0f * SK_Scalar1))); 1499 SkDEBUGF(("script '%s' == value %g != expected answer %g\n", script, value.fOperand.fScalar / (1.0f * SK_Scalar1), scriptTests[index].fScala rAnswer / (1.0f * SK_Scalar1)));
1500 SkASSERT(error < SK_Scalar1 / 10000); 1500 SkASSERT(error < SK_Scalar1 / 10000);
1501 break; 1501 break;
1502 case SkOperand2::kString: 1502 case SkOperand2::kString:
1503 SkASSERT(value.fOperand.fString->equals(scriptTests[index].fStri ngAnswer)); 1503 SkASSERT(value.fOperand.fString->equals(scriptTests[index].fStri ngAnswer));
1504 break; 1504 break;
1505 default: 1505 default:
1506 SkASSERT(0); 1506 SkASSERT(0);
1507 } 1507 }
1508 } 1508 }
1509 #endif // SK_SUPPORT_UNITTEST 1509 #endif // SK_SUPPORT_UNITTEST
1510 } 1510 }
1511 #endif // SK_DEBUG 1511 #endif // SK_DEBUG
OLDNEW
« no previous file with comments | « src/animator/SkScript.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698