text
stringlengths
0
15.7k
source
stringlengths
6
112
return _splitPattern(trim text theText, "\\s+")
lns3.scpt
else if matchFormat is case insensitivity then
lns3.scpt
return _splitText(theText, theSeparator)
lns3.scpt
return _splitPattern(theText, theSeparator)
lns3.scpt
_error("split text", eText, eNumber, eFrom, eTo)
lns3.scpt
end split text
lns3.scpt
to join text theList using separatorText : ""
lns3.scpt
return _joinText(_support's asListParameter(theList, ""), _support's asTextParameter(separatorText, "using"))
lns3.scpt
_error("join text", eText, eNumber, eFrom, eTo)
lns3.scpt
end join text
lns3.scpt
to split paragraphs theText
lns3.scpt
return paragraphs of _support's asTextParameter(theText, "")
lns3.scpt
_error("split paragraphs", eText, eNumber, eFrom, eTo)
lns3.scpt
end split paragraphs
lns3.scpt
to join paragraphs theList using lineBreakType : (OS X line breaks)
lns3.scpt
return _joinText(_support's asListParameter(theList, ""), _asLineBreakParameter(lineBreakType, "using"))
lns3.scpt
_error("join paragraphs", eText, eNumber, eFrom, eTo)
lns3.scpt
end join paragraphs
lns3.scpt
_support's throwCommandError("TestTools", handlerName, eText, eNumber, eFrom, eTo)
lns3.scpt
property _TestSupport : a reference to script "TestSupport" -- sub-library embedded in TestTools.scptd
lns3.scpt
property _AbortedAssertionError : 8001 -- raised by `assert…` handlers upon failed assertion to terminate that test
lns3.scpt
script _AbortedAssertionToken -- when raising error number AbortedAssertionError, the `from` parameter should carry this unique identifier to confirm error was raised by TestTools, and isn't merely an error in the test code/code being tested that happens to use the same error number (in which case it should be treated ...
lns3.scpt
property _suiteObject : missing value -- the test suite object that was passed to `perform unit test`; assigned and cleared at start and end of `perform unit test`; may be used by assert handlers (e.g. `assert test error` uses it when calling a `call_NAME` handler)
lns3.scpt
property _testReport : missing value -- a single test_NAME handler may perform multiple asserts, the result of each is recorded in TestReport object here
lns3.scpt
property _testHandlerName : missing value -- used to generate default `call_NAME` handler name for a `test_NAME` handler
lns3.scpt
to __performunittestforsuite__(suiteObject, {suiteName, handlerName, isStyled})
lns3.scpt
set _testReport to _TestSupport's makeTestReport(suiteName, handlerName, isStyled)
lns3.scpt
if _support's hasHandler(a reference to configure_skipTests of suiteObject) then
lns3.scpt
set skipInfo to suiteObject's configure_skipTests()
lns3.scpt
set skipInfo to skipInfo -- make sure configure_skipTests actually returned a value
lns3.scpt
on error number -2753
lns3.scpt
error "‘configure_skipTests’ didn’t return anything (e.g. to run all tests in suite, return ‘missing value’)." number -2753 from suiteObject to {record, text, missing value}
lns3.scpt
return _testReport
lns3.scpt
if skipInfo is not missing value then -- (missing value = run test; text = skip suite; record = run/skip test)
lns3.scpt
if _TestSupport's isType(skipInfo, record) then -- check if this test should be skipped
lns3.scpt
set skipReason to ((current application's NSDictionary's dictionaryWithDictionary:skipInfo)'s objectForKey:handlerName) as any
lns3.scpt
if skipReason is not missing value then
lns3.scpt
set skipReason to skipReason as text
lns3.scpt
error "‘configure_skipTests’ didn’t return valid record (‘" & handlerName & "’ property doesn’t contain text or ‘missing value’)." number -1700 from skipInfo to {text, missing value}
lns3.scpt
_testReport's addSkipped(handlerName, skipReason)
lns3.scpt
else if skipInfo is not missing value then -- skip the whole suite
lns3.scpt
set skipReason to skipInfo as text
lns3.scpt
error "‘configure_skipTests’ didn’t return record, text, or ‘missing value’." number -1700 from skipInfo to {record, text, missing value}
lns3.scpt
_testReport's skipSuite(skipReason)
lns3.scpt
on error eText number eNumber from eFrom to eTo partial result ePartial
lns3.scpt
_testReport's addBroken("configure_skipTests", "broke due to error", "", ¬
lns3.scpt
{{"unexpected error", _TestSupport's makeCaughtErrorRecord(eText, eNumber, eFrom, eTo, ePartial)}})
lns3.scpt
set _suiteObject to suiteObject
lns3.scpt
set _testHandlerName to handlerName
lns3.scpt
if _support's hasHandler(a reference to configure_setUp of suiteObject) then
lns3.scpt
suiteObject's configure_setUp()
lns3.scpt
_testReport's addBroken("configure_setUp", "broke due to error", "", ¬
lns3.scpt
set _suiteObject to missing value
lns3.scpt
set testObject to _TestSupport's makeTestObject(suiteObject, handlerName)
lns3.scpt
if _support's hasHandler(a reference to configure_doTest of suiteObject) then
lns3.scpt
suiteObject's configure_doTest(testObject)
lns3.scpt
testObject's doTest()
lns3.scpt
on error eText number eNumber from eFrom to eTo partial result ePartial -- test failed
lns3.scpt
if not (eNumber = _AbortedAssertionError and eFrom is _AbortedAssertionToken) then -- check if failure was already reported, and this is the subsequent abort, in which case ignore; if not, it's an error in either the test_NAME handler or the code being tested, so report it
lns3.scpt
_testReport's addFailure(handlerName, "(e.g. error in code being tested/bug in test handler)", "", ¬
lns3.scpt
{{"unexpected error", _TestSupport's makeCaughtErrorRecord(eText, eNumber, eFrom, eTo, ePartial)}}) -- TO DO: without stack trace support, there's no way to distinguish an error raised by the code being tested versus an error caused by a bug in the test code, so we can only say error was 'unexpected' and leave user to ...
lns3.scpt
if _support's hasHandler(a reference to configure_tearDown of suiteObject) then
lns3.scpt
suiteObject's configure_tearDown()
lns3.scpt
_testReport's addBroken("configure_tearDown", "broke due to error", "", ¬
lns3.scpt
return _testReport -- TO DO: wrapping all the test data (result values, error info, status, etc) in a script object and returning that preserves AS context info and AS types across the AE bridge; the script object can then be loaded into a new OSAID and its methods called to extract each bit of data in turn for formatt...
lns3.scpt
end __performunittestforsuite__
lns3.scpt
to _asCheckObjectParameter(checkObject, defaultCheckObject)
lns3.scpt
if checkObject is missing value then set checkObject to defaultCheckObject
lns3.scpt
set checkObject to _support's asScriptParameter(checkObject, "using")
lns3.scpt
if not _support's hasHandler(a reference to compareObjects of checkObject) then error "Bad ‘using’ parameter (script object doesn’t contain a ‘compareObjects’ handler)." number -1728 from checkObject
lns3.scpt
return checkObject
lns3.scpt
end _asCheckObjectParameter
lns3.scpt
to _asCheckObjectResult(isEqual)
lns3.scpt
if {isEqual} is not in {true, false} then error "Check object did not return a boolean result." number -1703 from isEqual to boolean
lns3.scpt
return isEqual
lns3.scpt
end _asCheckObjectResult
lns3.scpt
to exact equality check
lns3.scpt
script ExactEqualityCheck
lns3.scpt
to compareObjects(expectedValue, actualValue)
lns3.scpt
set refsCount to count {expectedValue, actualValue} each specifier
lns3.scpt
if refsCount = 1 or (refsCount = 0 and class of expectedValue is not class of actualValue) then return false
lns3.scpt
return expectedValue is actualValue
lns3.scpt
end compareObjects
lns3.scpt
end exact equality check
lns3.scpt
property _defaultEqualityCheck : exact equality check
lns3.scpt
to multiple choice check using checkObject : (missing value)
lns3.scpt
set checkObject to _asCheckObjectParameter(checkObject, _defaultEqualityCheck)
lns3.scpt
script MultipleChoiceCheck
lns3.scpt
to compareObjects(expectedValues, actualValue)
lns3.scpt
if (count {expectedValues} each list) = 0 or length of expectedValues < 2 then error "Invalid expected values (multiple choice check’s ‘using’ parameter requires a list of two or more expected values)." number -1703 from expectedValue
lns3.scpt
repeat with expectedValueRef in expectedValues
lns3.scpt
if _asCheckObjectResult(checkObject's compareObjects(expectedValueRef's contents, actualValue)) then return true
lns3.scpt
_error("numeric equality check", eText, eNumber, eFrom, eTo)
lns3.scpt
end multiple choice check
lns3.scpt
to numeric equality check matching types isSameTypeRequired : (true) -- ignores slight differences due to floating point's limited precision when comparing real numbers -- TO DO: allow magnitude to be optionally specified?
lns3.scpt
if _support's asBooleanParameter(isSameTypeRequired, "matching types") then
lns3.scpt
set checkType to real
lns3.scpt
set checkType to number
lns3.scpt
script NumericalEqualityCheck
lns3.scpt
property _isEqualDelta : 1.0E-12
lns3.scpt