diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index c54a188..e2f817f 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1,416 +1,419 @@ 2, 'class' => array( 'AASTNode' => 'parser/aast/api/AASTNode.php', 'AASTNodeList' => 'parser/aast/api/AASTNodeList.php', 'AASTToken' => 'parser/aast/api/AASTToken.php', 'AASTTree' => 'parser/aast/api/AASTTree.php', 'AbstractDirectedGraph' => 'utils/AbstractDirectedGraph.php', 'AbstractDirectedGraphTestCase' => 'utils/__tests__/AbstractDirectedGraphTestCase.php', 'AphrontDatabaseConnection' => 'aphront/storage/connection/AphrontDatabaseConnection.php', 'AphrontDatabaseTransactionState' => 'aphront/storage/connection/AphrontDatabaseTransactionState.php', 'AphrontIsolatedDatabaseConnection' => 'aphront/storage/connection/AphrontIsolatedDatabaseConnection.php', 'AphrontMySQLDatabaseConnection' => 'aphront/storage/connection/mysql/AphrontMySQLDatabaseConnection.php', 'AphrontMySQLDatabaseConnectionBase' => 'aphront/storage/connection/mysql/AphrontMySQLDatabaseConnectionBase.php', 'AphrontMySQLiDatabaseConnection' => 'aphront/storage/connection/mysql/AphrontMySQLiDatabaseConnection.php', 'AphrontQueryAccessDeniedException' => 'aphront/storage/exception/AphrontQueryAccessDeniedException.php', 'AphrontQueryConnectionException' => 'aphront/storage/exception/AphrontQueryConnectionException.php', 'AphrontQueryConnectionLostException' => 'aphront/storage/exception/AphrontQueryConnectionLostException.php', 'AphrontQueryCountException' => 'aphront/storage/exception/AphrontQueryCountException.php', 'AphrontQueryDeadlockException' => 'aphront/storage/exception/AphrontQueryDeadlockException.php', 'AphrontQueryDuplicateKeyException' => 'aphront/storage/exception/AphrontQueryDuplicateKeyException.php', 'AphrontQueryException' => 'aphront/storage/exception/AphrontQueryException.php', 'AphrontQueryNotSupportedException' => 'aphront/storage/exception/AphrontQueryNotSupportedException.php', 'AphrontQueryObjectMissingException' => 'aphront/storage/exception/AphrontQueryObjectMissingException.php', 'AphrontQueryParameterException' => 'aphront/storage/exception/AphrontQueryParameterException.php', 'AphrontQueryRecoverableException' => 'aphront/storage/exception/AphrontQueryRecoverableException.php', 'AphrontQuerySchemaException' => 'aphront/storage/exception/AphrontQuerySchemaException.php', 'AphrontScopedUnguardedWriteCapability' => 'aphront/writeguard/AphrontScopedUnguardedWriteCapability.php', 'AphrontWriteGuard' => 'aphront/writeguard/AphrontWriteGuard.php', 'BaseHTTPFuture' => 'future/http/BaseHTTPFuture.php', 'CommandException' => 'future/CommandException.php', 'ConduitClient' => 'conduit/ConduitClient.php', 'ConduitClientException' => 'conduit/ConduitClientException.php', 'ConduitFuture' => 'conduit/ConduitFuture.php', 'ExecFuture' => 'future/ExecFuture.php', 'ExecFutureTestCase' => 'future/__tests__/ExecFutureTestCase.php', 'FileFinder' => 'filesystem/FileFinder.php', 'FileList' => 'filesystem/FileList.php', 'Filesystem' => 'filesystem/Filesystem.php', 'FilesystemException' => 'filesystem/FilesystemException.php', 'Future' => 'future/Future.php', 'FutureIterator' => 'future/FutureIterator.php', 'FutureIteratorTestCase' => 'future/__tests__/FutureIteratorTestCase.php', 'FutureProxy' => 'future/FutureProxy.php', 'HTTPFuture' => 'future/http/HTTPFuture.php', 'HTTPFutureResponseStatus' => 'future/http/status/HTTPFutureResponseStatus.php', 'HTTPFutureResponseStatusCURL' => 'future/http/status/HTTPFutureResponseStatusCURL.php', 'HTTPFutureResponseStatusHTTP' => 'future/http/status/HTTPFutureResponseStatusHTTP.php', 'HTTPFutureResponseStatusParse' => 'future/http/status/HTTPFutureResponseStatusParse.php', 'HTTPFutureResponseStatusTransport' => 'future/http/status/HTTPFutureResponseStatusTransport.php', 'HTTPSFuture' => 'future/http/HTTPSFuture.php', 'ImmediateFuture' => 'future/ImmediateFuture.php', 'LinesOfALarge' => 'filesystem/linesofalarge/LinesOfALarge.php', 'LinesOfALargeExecFuture' => 'filesystem/linesofalarge/LinesOfALargeExecFuture.php', 'LinesOfALargeExecFutureTestCase' => 'filesystem/linesofalarge/__tests__/LinesOfALargeExecFutureTestCase.php', 'LinesOfALargeFile' => 'filesystem/linesofalarge/LinesOfALargeFile.php', 'LinesOfALargeFileTestCase' => 'filesystem/linesofalarge/__tests__/LinesOfALargeFileTestCase.php', 'MFilterTestHelper' => 'utils/__tests__/MFilterTestHelper.php', 'PhutilAWSEC2Future' => 'future/aws/PhutilAWSEC2Future.php', 'PhutilAWSException' => 'future/aws/PhutilAWSException.php', 'PhutilAWSFuture' => 'future/aws/PhutilAWSFuture.php', 'PhutilAggregateException' => 'error/PhutilAggregateException.php', 'PhutilArgumentParser' => 'parser/argument/PhutilArgumentParser.php', 'PhutilArgumentParserException' => 'parser/argument/exception/PhutilArgumentParserException.php', 'PhutilArgumentParserTestCase' => 'parser/argument/__tests__/PhutilArgumentParserTestCase.php', 'PhutilArgumentSpecification' => 'parser/argument/PhutilArgumentSpecification.php', 'PhutilArgumentSpecificationException' => 'parser/argument/exception/PhutilArgumentSpecificationException.php', 'PhutilArgumentSpecificationTestCase' => 'parser/argument/__tests__/PhutilArgumentSpecificationTestCase.php', 'PhutilArgumentUsageException' => 'parser/argument/exception/PhutilArgumentUsageException.php', 'PhutilArgumentWorkflow' => 'parser/argument/workflow/PhutilArgumentWorkflow.php', 'PhutilBufferedIterator' => 'utils/PhutilBufferedIterator.php', 'PhutilBufferedIteratorExample' => 'utils/PhutilBufferedIteratorExample.php', 'PhutilBufferedIteratorTestCase' => 'utils/__tests__/PhutilBufferedIteratorTestCase.php', 'PhutilChannel' => 'channel/PhutilChannel.php', 'PhutilChannelChannel' => 'channel/PhutilChannelChannel.php', 'PhutilConsole' => 'console/PhutilConsole.php', 'PhutilConsoleFormatter' => 'console/PhutilConsoleFormatter.php', 'PhutilConsoleMessage' => 'console/PhutilConsoleMessage.php', 'PhutilConsoleServer' => 'console/PhutilConsoleServer.php', 'PhutilConsoleServerChannel' => 'console/PhutilConsoleServerChannel.php', 'PhutilConsoleStdinNotInteractiveException' => 'console/PhutilConsoleStdinNotInteractiveException.php', 'PhutilConsoleSyntaxHighlighter' => 'markup/syntax/highlighter/PhutilConsoleSyntaxHighlighter.php', 'PhutilConsoleWrapTestCase' => 'console/__tests__/PhutilConsoleWrapTestCase.php', 'PhutilDaemon' => 'daemon/PhutilDaemon.php', 'PhutilDaemonOverseer' => 'daemon/PhutilDaemonOverseer.php', 'PhutilDefaultSyntaxHighlighter' => 'markup/syntax/highlighter/PhutilDefaultSyntaxHighlighter.php', 'PhutilDefaultSyntaxHighlighterEngine' => 'markup/syntax/engine/PhutilDefaultSyntaxHighlighterEngine.php', 'PhutilDefaultSyntaxHighlighterEnginePygmentsFuture' => 'markup/syntax/highlighter/pygments/PhutilDefaultSyntaxHighlighterEnginePygmentsFuture.php', 'PhutilDefaultSyntaxHighlighterEngineTestCase' => 'markup/syntax/engine/__tests__/PhutilDefaultSyntaxHighlighterEngineTestCase.php', 'PhutilDeferredLog' => 'filesystem/PhutilDeferredLog.php', 'PhutilDeferredLogTestCase' => 'filesystem/__tests__/PhutilDeferredLogTestCase.php', 'PhutilDivinerSyntaxHighlighter' => 'markup/syntax/highlighter/PhutilDivinerSyntaxHighlighter.php', 'PhutilDocblockParser' => 'parser/PhutilDocblockParser.php', 'PhutilDocblockParserTestCase' => 'parser/__tests__/PhutilDocblockParserTestCase.php', 'PhutilEmailAddress' => 'parser/PhutilEmailAddress.php', 'PhutilEmailAddressTestCase' => 'parser/__tests__/PhutilEmailAddressTestCase.php', 'PhutilErrorHandler' => 'error/PhutilErrorHandler.php', 'PhutilEvent' => 'events/PhutilEvent.php', 'PhutilEventConstants' => 'events/constant/PhutilEventConstants.php', 'PhutilEventEngine' => 'events/PhutilEventEngine.php', 'PhutilEventListener' => 'events/PhutilEventListener.php', 'PhutilEventType' => 'events/constant/PhutilEventType.php', 'PhutilExcessiveServiceCallsDaemon' => 'daemon/torture/PhutilExcessiveServiceCallsDaemon.php', 'PhutilExecChannel' => 'channel/PhutilExecChannel.php', 'PhutilFatalDaemon' => 'daemon/torture/PhutilFatalDaemon.php', 'PhutilFileLock' => 'filesystem/PhutilFileLock.php', 'PhutilFileLockTestCase' => 'filesystem/__tests__/PhutilFileLockTestCase.php', 'PhutilFileTree' => 'filesystem/PhutilFileTree.php', 'PhutilGitURI' => 'parser/PhutilGitURI.php', 'PhutilGitURITestCase' => 'parser/__tests__/PhutilGitURITestCase.php', 'PhutilHangForeverDaemon' => 'daemon/torture/PhutilHangForeverDaemon.php', 'PhutilHelpArgumentWorkflow' => 'parser/argument/workflow/PhutilHelpArgumentWorkflow.php', 'PhutilInteractiveEditor' => 'console/PhutilInteractiveEditor.php', 'PhutilJSON' => 'parser/PhutilJSON.php', 'PhutilJSONProtocolChannel' => 'channel/PhutilJSONProtocolChannel.php', 'PhutilJSONProtocolChannelTestCase' => 'channel/__tests__/PhutilJSONProtocolChannelTestCase.php', 'PhutilJSONTestCase' => 'parser/__tests__/PhutilJSONTestCase.php', 'PhutilLanguageGuesser' => 'parser/PhutilLanguageGuesser.php', 'PhutilLanguageGuesserTestCase' => 'parser/__tests__/PhutilLanguageGuesserTestCase.php', 'PhutilLexer' => 'lexer/PhutilLexer.php', 'PhutilLexerSyntaxHighlighter' => 'markup/syntax/highlighter/PhutilLexerSyntaxHighlighter.php', 'PhutilLock' => 'filesystem/PhutilLock.php', 'PhutilLockException' => 'filesystem/PhutilLockException.php', 'PhutilMarkupEngine' => 'markup/PhutilMarkupEngine.php', 'PhutilMarkupTestCase' => 'markup/__tests__/PhutilMarkupTestCase.php', 'PhutilMissingSymbolException' => 'symbols/exception/PhutilMissingSymbolException.php', 'PhutilNiceDaemon' => 'daemon/torture/PhutilNiceDaemon.php', 'PhutilOpaqueEnvelope' => 'error/PhutilOpaqueEnvelope.php', 'PhutilOpaqueEnvelopeKey' => 'error/PhutilOpaqueEnvelopeKey.php', 'PhutilOpaqueEnvelopeTestCase' => 'error/__tests__/PhutilOpaqueEnvelopeTestCase.php', 'PhutilPHPFragmentLexer' => 'lexer/PhutilPHPFragmentLexer.php', 'PhutilPHPFragmentLexerHighlighterTestCase' => 'markup/syntax/highlighter/__tests__/PhutilPHPFragmentLexerHighlighterTestCase.php', 'PhutilPHPFragmentLexerTestCase' => 'lexer/__tests__/PhutilPHPFragmentLexerTestCase.php', 'PhutilPHPObjectProtocolChannel' => 'channel/PhutilPHPObjectProtocolChannel.php', 'PhutilPHPObjectProtocolChannelTestCase' => 'channel/__tests__/PhutilPHPObjectProtocolChannelTestCase.php', 'PhutilPHTTestCase' => 'internationalization/__tests__/PhutilPHTTestCase.php', 'PhutilPerson' => 'internationalization/PhutilPerson.php', 'PhutilPersonTest' => 'internationalization/__tests__/PhutilPersonTest.php', 'PhutilProcessGroupDaemon' => 'daemon/torture/PhutilProcessGroupDaemon.php', 'PhutilProtocolChannel' => 'channel/PhutilProtocolChannel.php', 'PhutilPygmentsSyntaxHighlighter' => 'markup/syntax/highlighter/PhutilPygmentsSyntaxHighlighter.php', 'PhutilRainbowSyntaxHighlighter' => 'markup/syntax/highlighter/PhutilRainbowSyntaxHighlighter.php', 'PhutilReadableSerializer' => 'readableserializer/PhutilReadableSerializer.php', 'PhutilRemarkupBlockStorage' => 'markup/engine/remarkup/PhutilRemarkupBlockStorage.php', 'PhutilRemarkupEngine' => 'markup/engine/PhutilRemarkupEngine.php', 'PhutilRemarkupEngineBlockRule' => 'markup/engine/remarkup/blockrule/PhutilRemarkupEngineBlockRule.php', 'PhutilRemarkupEngineRemarkupCodeBlockRule' => 'markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupCodeBlockRule.php', 'PhutilRemarkupEngineRemarkupDefaultBlockRule' => 'markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupDefaultBlockRule.php', 'PhutilRemarkupEngineRemarkupHeaderBlockRule' => 'markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupHeaderBlockRule.php', 'PhutilRemarkupEngineRemarkupInlineBlockRule' => 'markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupInlineBlockRule.php', 'PhutilRemarkupEngineRemarkupListBlockRule' => 'markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupListBlockRule.php', 'PhutilRemarkupEngineRemarkupLiteralBlockRule' => 'markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupLiteralBlockRule.php', 'PhutilRemarkupEngineRemarkupNoteBlockRule' => 'markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupNoteBlockRule.php', 'PhutilRemarkupEngineRemarkupQuotesBlockRule' => 'markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupQuotesBlockRule.php', 'PhutilRemarkupEngineRemarkupTableBlockRule' => 'markup/engine/remarkup/blockrule/PhutilRemarkupEngineRemarkupTableBlockRule.php', 'PhutilRemarkupEngineTestCase' => 'markup/engine/__tests__/PhutilRemarkupEngineTestCase.php', 'PhutilRemarkupRule' => 'markup/engine/remarkup/markuprule/PhutilRemarkupRule.php', 'PhutilRemarkupRuleBold' => 'markup/engine/remarkup/markuprule/PhutilRemarkupRuleBold.php', 'PhutilRemarkupRuleDel' => 'markup/engine/remarkup/markuprule/PhutilRemarkupRuleDel.php', 'PhutilRemarkupRuleDocumentLink' => 'markup/engine/remarkup/markuprule/PhutilRemarkupRuleDocumentLink.php', 'PhutilRemarkupRuleEscapeHTML' => 'markup/engine/remarkup/markuprule/PhutilRemarkupRuleEscapeHTML.php', 'PhutilRemarkupRuleEscapeRemarkup' => 'markup/engine/remarkup/markuprule/PhutilRemarkupRuleEscapeRemarkup.php', 'PhutilRemarkupRuleHyperlink' => 'markup/engine/remarkup/markuprule/PhutilRemarkupRuleHyperlink.php', 'PhutilRemarkupRuleItalic' => 'markup/engine/remarkup/markuprule/PhutilRemarkupRuleItalic.php', 'PhutilRemarkupRuleLinebreaks' => 'markup/engine/remarkup/markuprule/PhutilRemarkupRuleLinebreaks.php', 'PhutilRemarkupRuleMonospace' => 'markup/engine/remarkup/markuprule/PhutilRemarkupRuleMonospace.php', 'PhutilSaturateStdoutDaemon' => 'daemon/torture/PhutilSaturateStdoutDaemon.php', 'PhutilServiceProfiler' => 'serviceprofiler/PhutilServiceProfiler.php', 'PhutilSimpleOptions' => 'parser/PhutilSimpleOptions.php', 'PhutilSimpleOptionsTestCase' => 'parser/__tests__/PhutilSimpleOptionsTestCase.php', 'PhutilSocketChannel' => 'channel/PhutilSocketChannel.php', 'PhutilSprite' => 'sprites/PhutilSprite.php', 'PhutilSpriteSheet' => 'sprites/PhutilSpriteSheet.php', 'PhutilSymbolLoader' => 'symbols/PhutilSymbolLoader.php', 'PhutilSyntaxHighlighter' => 'markup/syntax/highlighter/PhutilSyntaxHighlighter.php', 'PhutilSyntaxHighlighterEngine' => 'markup/syntax/engine/PhutilSyntaxHighlighterEngine.php', 'PhutilSyntaxHighlighterException' => 'markup/syntax/highlighter/PhutilSyntaxHighlighterException.php', + 'PhutilTestCase' => 'infrastructure/testing/PhutilTestCase.php', 'PhutilTortureTestDaemon' => 'daemon/torture/PhutilTortureTestDaemon.php', 'PhutilTranslator' => 'internationalization/PhutilTranslator.php', 'PhutilTranslatorTestCase' => 'internationalization/__tests__/PhutilTranslatorTestCase.php', 'PhutilURI' => 'parser/PhutilURI.php', 'PhutilURITestCase' => 'parser/__tests__/PhutilURITestCase.php', 'PhutilUTF8TestCase' => 'utils/__tests__/PhutilUTF8TestCase.php', 'PhutilUtilsTestCase' => 'utils/__tests__/PhutilUtilsTestCase.php', 'PhutilXHPASTSyntaxHighlighter' => 'markup/syntax/highlighter/PhutilXHPASTSyntaxHighlighter.php', 'PhutilXHPASTSyntaxHighlighterTestCase' => 'markup/syntax/highlighter/__tests__/PhutilXHPASTSyntaxHighlighterTestCase.php', 'TempFile' => 'filesystem/TempFile.php', 'TestAbstractDirectedGraph' => 'utils/__tests__/TestAbstractDirectedGraph.php', 'XHPASTNode' => 'parser/xhpast/api/XHPASTNode.php', 'XHPASTSyntaxErrorException' => 'parser/xhpast/api/XHPASTSyntaxErrorException.php', 'XHPASTToken' => 'parser/xhpast/api/XHPASTToken.php', 'XHPASTTree' => 'parser/xhpast/api/XHPASTTree.php', 'XHPASTTreeTestCase' => 'parser/xhpast/api/__tests__/XHPASTTreeTestCase.php', ), 'function' => array( 'Futures' => 'future/functions.php', '_qsprintf_check_scalar_type' => 'xsprintf/qsprintf.php', '_qsprintf_check_type' => 'xsprintf/qsprintf.php', 'array_mergev' => 'utils/utils.php', 'array_select_keys' => 'utils/utils.php', 'assert_instances_of' => 'utils/utils.php', 'coalesce' => 'utils/utils.php', 'csprintf' => 'xsprintf/csprintf.php', 'exec_manual' => 'future/execx.php', 'execx' => 'future/execx.php', 'head' => 'utils/utils.php', 'head_key' => 'utils/utils.php', 'hsprintf' => 'markup/render.php', 'id' => 'utils/utils.php', 'idx' => 'utils/utils.php', 'ifilter' => 'utils/utils.php', 'igroup' => 'utils/utils.php', 'ipull' => 'utils/utils.php', 'isort' => 'utils/utils.php', 'jsprintf' => 'xsprintf/jsprintf.php', 'last' => 'utils/utils.php', 'last_key' => 'utils/utils.php', 'ldap_sprintf' => 'xsprintf/ldapsprintf.php', 'mfilter' => 'utils/utils.php', 'mgroup' => 'utils/utils.php', 'mpull' => 'utils/utils.php', 'msort' => 'utils/utils.php', 'newv' => 'utils/utils.php', 'nonempty' => 'utils/utils.php', 'phlog' => 'error/phlog.php', 'pht' => 'internationalization/pht.php', 'phutil_console_confirm' => 'console/format.php', 'phutil_console_format' => 'console/format.php', 'phutil_console_prompt' => 'console/format.php', 'phutil_console_require_tty' => 'console/format.php', 'phutil_console_wrap' => 'console/format.php', 'phutil_deprecated' => 'moduleutils/moduleutils.php', 'phutil_error_listener_example' => 'error/phlog.php', 'phutil_escape_html' => 'markup/render.php', 'phutil_escape_uri' => 'markup/render.php', 'phutil_escape_uri_path_component' => 'markup/render.php', 'phutil_get_library_name_for_root' => 'moduleutils/moduleutils.php', 'phutil_get_library_root' => 'moduleutils/moduleutils.php', 'phutil_get_library_root_for_path' => 'moduleutils/moduleutils.php', 'phutil_is_utf8' => 'utils/utf8.php', 'phutil_passthru' => 'future/execx.php', 'phutil_render_tag' => 'markup/render.php', + 'phutil_split_lines' => 'utils/utils.php', 'phutil_unescape_uri_path_component' => 'markup/render.php', 'phutil_utf8_convert' => 'utils/utf8.php', 'phutil_utf8_hard_wrap_html' => 'utils/utf8.php', 'phutil_utf8_shorten' => 'utils/utf8.php', 'phutil_utf8_strlen' => 'utils/utf8.php', 'phutil_utf8ize' => 'utils/utf8.php', 'phutil_utf8v' => 'utils/utf8.php', 'qsprintf' => 'xsprintf/qsprintf.php', 'queryfx' => 'xsprintf/queryfx.php', 'queryfx_all' => 'xsprintf/queryfx.php', 'queryfx_one' => 'xsprintf/queryfx.php', 'vcsprintf' => 'xsprintf/csprintf.php', 'vjsprintf' => 'xsprintf/jsprintf.php', 'vqsprintf' => 'xsprintf/qsprintf.php', 'vqueryfx' => 'xsprintf/queryfx.php', 'vqueryfx_all' => 'xsprintf/queryfx.php', 'xhp_parser_node_constants' => 'parser/xhpast/parser_nodes.php', 'xhpast_get_binary_path' => 'parser/xhpast/bin/xhpast_parse.php', 'xhpast_get_build_instructions' => 'parser/xhpast/bin/xhpast_parse.php', 'xhpast_get_parser_future' => 'parser/xhpast/bin/xhpast_parse.php', 'xhpast_is_available' => 'parser/xhpast/bin/xhpast_parse.php', 'xhpast_parser_token_constants' => 'parser/xhpast/parser_tokens.php', 'xsprintf' => 'xsprintf/xsprintf.php', 'xsprintf_callback_example' => 'xsprintf/xsprintf.php', 'xsprintf_command' => 'xsprintf/csprintf.php', 'xsprintf_javascript' => 'xsprintf/jsprintf.php', 'xsprintf_ldap' => 'xsprintf/ldapsprintf.php', 'xsprintf_query' => 'xsprintf/qsprintf.php', ), 'xmap' => array( 'AASTNodeList' => array( 0 => 'Iterator', 1 => 'Countable', ), - 'AbstractDirectedGraphTestCase' => 'ArcanistPhutilTestCase', + 'AbstractDirectedGraphTestCase' => 'PhutilTestCase', 'AphrontIsolatedDatabaseConnection' => 'AphrontDatabaseConnection', 'AphrontMySQLDatabaseConnection' => 'AphrontMySQLDatabaseConnectionBase', 'AphrontMySQLDatabaseConnectionBase' => 'AphrontDatabaseConnection', 'AphrontMySQLiDatabaseConnection' => 'AphrontMySQLDatabaseConnectionBase', 'AphrontQueryAccessDeniedException' => 'AphrontQueryRecoverableException', 'AphrontQueryConnectionException' => 'AphrontQueryException', 'AphrontQueryConnectionLostException' => 'AphrontQueryRecoverableException', 'AphrontQueryCountException' => 'AphrontQueryException', 'AphrontQueryDeadlockException' => 'AphrontQueryRecoverableException', 'AphrontQueryDuplicateKeyException' => 'AphrontQueryException', 'AphrontQueryException' => 'Exception', 'AphrontQueryNotSupportedException' => 'AphrontQueryException', 'AphrontQueryObjectMissingException' => 'AphrontQueryException', 'AphrontQueryParameterException' => 'AphrontQueryException', 'AphrontQueryRecoverableException' => 'AphrontQueryException', 'AphrontQuerySchemaException' => 'AphrontQueryException', 'BaseHTTPFuture' => 'Future', 'CommandException' => 'Exception', 'ConduitClientException' => 'Exception', 'ConduitFuture' => 'FutureProxy', 'ExecFuture' => 'Future', - 'ExecFutureTestCase' => 'ArcanistPhutilTestCase', + 'ExecFutureTestCase' => 'PhutilTestCase', 'FilesystemException' => 'Exception', 'FutureIterator' => 'Iterator', - 'FutureIteratorTestCase' => 'ArcanistPhutilTestCase', + 'FutureIteratorTestCase' => 'PhutilTestCase', 'FutureProxy' => 'Future', 'HTTPFuture' => 'BaseHTTPFuture', 'HTTPFutureResponseStatus' => 'Exception', 'HTTPFutureResponseStatusCURL' => 'HTTPFutureResponseStatus', 'HTTPFutureResponseStatusHTTP' => 'HTTPFutureResponseStatus', 'HTTPFutureResponseStatusParse' => 'HTTPFutureResponseStatus', 'HTTPFutureResponseStatusTransport' => 'HTTPFutureResponseStatus', 'HTTPSFuture' => 'BaseHTTPFuture', 'ImmediateFuture' => 'Future', 'LinesOfALarge' => 'Iterator', 'LinesOfALargeExecFuture' => 'LinesOfALarge', - 'LinesOfALargeExecFutureTestCase' => 'ArcanistPhutilTestCase', + 'LinesOfALargeExecFutureTestCase' => 'PhutilTestCase', 'LinesOfALargeFile' => 'LinesOfALarge', - 'LinesOfALargeFileTestCase' => 'ArcanistPhutilTestCase', + 'LinesOfALargeFileTestCase' => 'PhutilTestCase', 'PhutilAWSEC2Future' => 'PhutilAWSFuture', 'PhutilAWSException' => 'Exception', 'PhutilAWSFuture' => 'FutureProxy', 'PhutilAggregateException' => 'Exception', 'PhutilArgumentParserException' => 'Exception', - 'PhutilArgumentParserTestCase' => 'ArcanistPhutilTestCase', + 'PhutilArgumentParserTestCase' => 'PhutilTestCase', 'PhutilArgumentSpecificationException' => 'PhutilArgumentParserException', - 'PhutilArgumentSpecificationTestCase' => 'ArcanistPhutilTestCase', + 'PhutilArgumentSpecificationTestCase' => 'PhutilTestCase', 'PhutilArgumentUsageException' => 'PhutilArgumentParserException', 'PhutilBufferedIterator' => 'Iterator', 'PhutilBufferedIteratorExample' => 'PhutilBufferedIterator', - 'PhutilBufferedIteratorTestCase' => 'ArcanistPhutilTestCase', + 'PhutilBufferedIteratorTestCase' => 'PhutilTestCase', 'PhutilChannelChannel' => 'PhutilChannel', 'PhutilConsoleServerChannel' => 'PhutilChannelChannel', 'PhutilConsoleStdinNotInteractiveException' => 'Exception', - 'PhutilConsoleWrapTestCase' => 'ArcanistPhutilTestCase', + 'PhutilConsoleWrapTestCase' => 'PhutilTestCase', 'PhutilDefaultSyntaxHighlighterEngine' => 'PhutilSyntaxHighlighterEngine', 'PhutilDefaultSyntaxHighlighterEnginePygmentsFuture' => 'FutureProxy', - 'PhutilDefaultSyntaxHighlighterEngineTestCase' => 'ArcanistPhutilTestCase', - 'PhutilDeferredLogTestCase' => 'ArcanistPhutilTestCase', - 'PhutilDocblockParserTestCase' => 'ArcanistPhutilTestCase', - 'PhutilEmailAddressTestCase' => 'ArcanistPhutilTestCase', + 'PhutilDefaultSyntaxHighlighterEngineTestCase' => 'PhutilTestCase', + 'PhutilDeferredLogTestCase' => 'PhutilTestCase', + 'PhutilDocblockParserTestCase' => 'PhutilTestCase', + 'PhutilEmailAddressTestCase' => 'PhutilTestCase', 'PhutilEventType' => 'PhutilEventConstants', 'PhutilExcessiveServiceCallsDaemon' => 'PhutilTortureTestDaemon', 'PhutilExecChannel' => 'PhutilChannel', 'PhutilFatalDaemon' => 'PhutilTortureTestDaemon', 'PhutilFileLock' => 'PhutilLock', - 'PhutilFileLockTestCase' => 'ArcanistPhutilTestCase', - 'PhutilGitURITestCase' => 'ArcanistPhutilTestCase', + 'PhutilFileLockTestCase' => 'PhutilTestCase', + 'PhutilGitURITestCase' => 'PhutilTestCase', 'PhutilHangForeverDaemon' => 'PhutilTortureTestDaemon', 'PhutilHelpArgumentWorkflow' => 'PhutilArgumentWorkflow', 'PhutilJSONProtocolChannel' => 'PhutilProtocolChannel', - 'PhutilJSONProtocolChannelTestCase' => 'ArcanistPhutilTestCase', - 'PhutilJSONTestCase' => 'ArcanistPhutilTestCase', - 'PhutilLanguageGuesserTestCase' => 'ArcanistPhutilTestCase', + 'PhutilJSONProtocolChannelTestCase' => 'PhutilTestCase', + 'PhutilJSONTestCase' => 'PhutilTestCase', + 'PhutilLanguageGuesserTestCase' => 'PhutilTestCase', 'PhutilLexerSyntaxHighlighter' => 'PhutilSyntaxHighlighter', 'PhutilLockException' => 'Exception', - 'PhutilMarkupTestCase' => 'ArcanistPhutilTestCase', + 'PhutilMarkupTestCase' => 'PhutilTestCase', 'PhutilMissingSymbolException' => 'Exception', 'PhutilNiceDaemon' => 'PhutilTortureTestDaemon', - 'PhutilOpaqueEnvelopeTestCase' => 'ArcanistPhutilTestCase', + 'PhutilOpaqueEnvelopeTestCase' => 'PhutilTestCase', 'PhutilPHPFragmentLexer' => 'PhutilLexer', - 'PhutilPHPFragmentLexerHighlighterTestCase' => 'ArcanistPhutilTestCase', - 'PhutilPHPFragmentLexerTestCase' => 'ArcanistPhutilTestCase', + 'PhutilPHPFragmentLexerHighlighterTestCase' => 'PhutilTestCase', + 'PhutilPHPFragmentLexerTestCase' => 'PhutilTestCase', 'PhutilPHPObjectProtocolChannel' => 'PhutilProtocolChannel', - 'PhutilPHPObjectProtocolChannelTestCase' => 'ArcanistPhutilTestCase', - 'PhutilPHTTestCase' => 'ArcanistPhutilTestCase', + 'PhutilPHPObjectProtocolChannelTestCase' => 'PhutilTestCase', + 'PhutilPHTTestCase' => 'PhutilTestCase', 'PhutilPersonTest' => 'PhutilPerson', 'PhutilProcessGroupDaemon' => 'PhutilTortureTestDaemon', 'PhutilProtocolChannel' => 'PhutilChannelChannel', 'PhutilRemarkupEngine' => 'PhutilMarkupEngine', 'PhutilRemarkupEngineRemarkupCodeBlockRule' => 'PhutilRemarkupEngineBlockRule', 'PhutilRemarkupEngineRemarkupDefaultBlockRule' => 'PhutilRemarkupEngineBlockRule', 'PhutilRemarkupEngineRemarkupHeaderBlockRule' => 'PhutilRemarkupEngineBlockRule', 'PhutilRemarkupEngineRemarkupInlineBlockRule' => 'PhutilRemarkupEngineBlockRule', 'PhutilRemarkupEngineRemarkupListBlockRule' => 'PhutilRemarkupEngineBlockRule', 'PhutilRemarkupEngineRemarkupLiteralBlockRule' => 'PhutilRemarkupEngineBlockRule', 'PhutilRemarkupEngineRemarkupNoteBlockRule' => 'PhutilRemarkupEngineBlockRule', 'PhutilRemarkupEngineRemarkupQuotesBlockRule' => 'PhutilRemarkupEngineBlockRule', 'PhutilRemarkupEngineRemarkupTableBlockRule' => 'PhutilRemarkupEngineBlockRule', - 'PhutilRemarkupEngineTestCase' => 'ArcanistPhutilTestCase', + 'PhutilRemarkupEngineTestCase' => 'PhutilTestCase', 'PhutilRemarkupRuleBold' => 'PhutilRemarkupRule', 'PhutilRemarkupRuleDel' => 'PhutilRemarkupRule', 'PhutilRemarkupRuleDocumentLink' => 'PhutilRemarkupRule', 'PhutilRemarkupRuleEscapeHTML' => 'PhutilRemarkupRule', 'PhutilRemarkupRuleEscapeRemarkup' => 'PhutilRemarkupRule', 'PhutilRemarkupRuleHyperlink' => 'PhutilRemarkupRule', 'PhutilRemarkupRuleItalic' => 'PhutilRemarkupRule', 'PhutilRemarkupRuleLinebreaks' => 'PhutilRemarkupRule', 'PhutilRemarkupRuleMonospace' => 'PhutilRemarkupRule', 'PhutilSaturateStdoutDaemon' => 'PhutilTortureTestDaemon', - 'PhutilSimpleOptionsTestCase' => 'ArcanistPhutilTestCase', + 'PhutilSimpleOptionsTestCase' => 'PhutilTestCase', 'PhutilSocketChannel' => 'PhutilChannel', 'PhutilSyntaxHighlighterException' => 'Exception', + 'PhutilTestCase' => 'ArcanistPhutilTestCase', 'PhutilTortureTestDaemon' => 'PhutilDaemon', - 'PhutilTranslatorTestCase' => 'ArcanistPhutilTestCase', - 'PhutilURITestCase' => 'ArcanistPhutilTestCase', - 'PhutilUTF8TestCase' => 'ArcanistPhutilTestCase', - 'PhutilUtilsTestCase' => 'ArcanistPhutilTestCase', - 'PhutilXHPASTSyntaxHighlighterTestCase' => 'ArcanistPhutilTestCase', + 'PhutilTranslatorTestCase' => 'PhutilTestCase', + 'PhutilURITestCase' => 'PhutilTestCase', + 'PhutilUTF8TestCase' => 'PhutilTestCase', + 'PhutilUtilsTestCase' => 'PhutilTestCase', + 'PhutilXHPASTSyntaxHighlighterTestCase' => 'PhutilTestCase', 'TestAbstractDirectedGraph' => 'AbstractDirectedGraph', 'XHPASTNode' => 'AASTNode', 'XHPASTSyntaxErrorException' => 'Exception', 'XHPASTToken' => 'AASTToken', 'XHPASTTree' => 'AASTTree', - 'XHPASTTreeTestCase' => 'ArcanistPhutilTestCase', + 'XHPASTTreeTestCase' => 'PhutilTestCase', ), )); diff --git a/src/channel/__tests__/PhutilJSONProtocolChannelTestCase.php b/src/channel/__tests__/PhutilJSONProtocolChannelTestCase.php index 2e33405..aca7f05 100644 --- a/src/channel/__tests__/PhutilJSONProtocolChannelTestCase.php +++ b/src/channel/__tests__/PhutilJSONProtocolChannelTestCase.php @@ -1,43 +1,42 @@ mt_rand(), 'list' => array(1, 2, 3), 'null' => null, ); $xp->write($dict); $xp->flush(); $result = $yp->waitForMessage(); $this->assertEqual( $dict, $result, "Values are identical."); } } diff --git a/src/channel/__tests__/PhutilPHPObjectProtocolChannelTestCase.php b/src/channel/__tests__/PhutilPHPObjectProtocolChannelTestCase.php index c558f91..b3a98a7 100644 --- a/src/channel/__tests__/PhutilPHPObjectProtocolChannelTestCase.php +++ b/src/channel/__tests__/PhutilPHPObjectProtocolChannelTestCase.php @@ -1,46 +1,45 @@ mt_rand(), ); $xp->write($object); $xp->flush(); $result = $yp->waitForMessage(); $this->assertEqual( true, (array)$object === (array)$result, "Values are identical."); $this->assertEqual( false, $object === $result, "Objects are not the same."); } } diff --git a/src/console/__tests__/PhutilConsoleWrapTestCase.php b/src/console/__tests__/PhutilConsoleWrapTestCase.php index f36dfef..83a846a 100644 --- a/src/console/__tests__/PhutilConsoleWrapTestCase.php +++ b/src/console/__tests__/PhutilConsoleWrapTestCase.php @@ -1,66 +1,66 @@ assertEqual( Filesystem::readFile($dir.$file.'.expect'), phutil_console_wrap(Filesystem::readFile($dir.$file)), $file); } } } public function testConsoleWrap() { $this->assertEqual( phutil_console_format( "** ERROR ** abc abc abc abc abc abc abc abc abc abc ". "abc abc abc abc abc abc abc\nabc abc abc abc abc abc abc abc abc ". "abc abc!"), phutil_console_wrap( phutil_console_format( "** ERROR ** abc abc abc abc abc abc abc abc abc abc ". "abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc ". "abc abc!")), 'ANSI escape sequences should not contribute toward wrap width.'); } public function testWrapIndent() { $turtles = <<assertEqual( $turtles, phutil_console_wrap( rtrim(str_repeat('turtle ', 20)), $indent = 20)); } } diff --git a/src/error/__tests__/PhutilOpaqueEnvelopeTestCase.php b/src/error/__tests__/PhutilOpaqueEnvelopeTestCase.php index 74e0bd1..87ef8a1 100644 --- a/src/error/__tests__/PhutilOpaqueEnvelopeTestCase.php +++ b/src/error/__tests__/PhutilOpaqueEnvelopeTestCase.php @@ -1,73 +1,73 @@ assertEqual( false, strpos(var_export($envelope, true), $secret)); $this->assertEqual( false, strpos(print_r($envelope, true), $secret)); ob_start(); var_dump($envelope); $dump = ob_get_clean(); $this->assertEqual( false, strpos($dump, $secret)); try { $this->throwTrace($envelope); } catch (Exception $ex) { $trace = $ex->getTrace(); $this->assertEqual( false, strpos(print_r($trace, true), $secret)); } $backtrace = $this->getBacktrace($envelope); $this->assertEqual( false, strpos(print_r($backtrace, true), $secret)); $this->assertEqual($secret, $envelope->openEnvelope()); } private function throwTrace($v) { throw new Exception("!"); } private function getBacktrace($v) { return debug_backtrace(); } } diff --git a/src/filesystem/__tests__/PhutilDeferredLogTestCase.php b/src/filesystem/__tests__/PhutilDeferredLogTestCase.php index d1c4212..d3ffe75 100644 --- a/src/filesystem/__tests__/PhutilDeferredLogTestCase.php +++ b/src/filesystem/__tests__/PhutilDeferredLogTestCase.php @@ -1,149 +1,149 @@ checkLog( "derp\n", "derp", array()); $this->checkLog( "[20 Aug 1984] alincoln\n", "[%T] %u", array( 'T' => '20 Aug 1984', 'u' => 'alincoln', )); $this->checkLog( "%%%%%\n", "%%%%%%%%%%", array( '%' => '%', )); $this->checkLog( "\\000\\001\\002\n", "%a%b%c", array( 'a' => chr(0), 'b' => chr(1), 'c' => chr(2), )); $this->checkLog( "Download: 100%\n", "Download: %C", array( 'C' => '100%', )); $this->checkLog( "- bee -\n", "%a %b %c", array( 'b' => 'bee', )); $this->checkLog( "\\\\\n", "%b", array( 'b' => '\\', )); $this->checkLog( "a\t\\t\n", "%a\t%b", array( 'a' => 'a', 'b' => "\t", )); $this->checkLog( "\1ab\n", "\1a%a", array( 'a' => 'b', )); $this->checkLog( "a % xb\n", "%a %% x%b", array( 'a' => 'a', 'b' => 'b', )); } public function testLogWriteFailure() { $caught = null; try { if (phutil_is_hiphop_runtime()) { // In HipHop exceptions thrown in destructors are not normally // catchable, so call __destruct() explicitly. $log = new PhutilDeferredLog('/derp/derp/derp/derp/derp', 'derp'); $log->__destruct(); } else { new PhutilDeferredLog('/derp/derp/derp/derp/derp', 'derp'); } } catch (Exception $ex) { $caught = $ex; } $this->assertEqual(true, $caught instanceof Exception); } public function testManyWriters() { $root = phutil_get_library_root('phutil').'/../'; $bin = $root.'scripts/test/deferred_log.php'; $n_writers = 3; $n_lines = 8; $tmp = new TempFile(); $futures = array(); for ($ii = 0; $ii < $n_writers; $ii++) { $futures[] = new ExecFuture("%s %d %s", $bin, $n_lines, (string)$tmp); } Futures($futures)->resolveAll(); $this->assertEqual( str_repeat("abcdefghijklmnopqrstuvwxyz\n", $n_writers * $n_lines), Filesystem::readFile($tmp)); } private function checkLog($expect, $format, $data) { $tmp = new TempFile(); $log = new PhutilDeferredLog($tmp, $format); $log->setData($data); unset($log); $this->assertEqual($expect, Filesystem::readFile($tmp), $format); } } diff --git a/src/filesystem/__tests__/PhutilFileLockTestCase.php b/src/filesystem/__tests__/PhutilFileLockTestCase.php index 79f8784..be02bc7 100644 --- a/src/filesystem/__tests__/PhutilFileLockTestCase.php +++ b/src/filesystem/__tests__/PhutilFileLockTestCase.php @@ -1,228 +1,228 @@ assertEqual( true, $this->lockTest($file)); $this->assertEqual( true, $this->lockTest($file)); } public function testLockHolding() { // When a process is holding a lock, other processes should be unable // to acquire it. $file = new TempFile(); $hold = $this->holdLock($file); $this->assertEqual( false, $this->lockTest($file)); $hold->resolveKill(); $this->assertEqual( true, $this->lockTest($file)); } public function testInProcessLocking() { // Other processes should be unable to lock a file if we hold the lock. $file = new TempFile(); $lock = PhutilFileLock::newForPath($file); $lock->lock(); $this->assertEqual( false, $this->lockTest($file)); $lock->unlock(); $this->assertEqual( true, $this->lockTest($file)); } public function testInProcessHolding() { // We should be unable to lock a file if another process is holding the // lock. $file = new TempFile(); $lock = PhutilFileLock::newForPath($file); $hold = $this->holdLock($file); $caught = null; try { $lock->lock(); } catch (PhutilLockException $ex) { $caught = $ex; } $this->assertEqual( true, ($caught instanceof PhutilLockException)); $hold->resolveKill(); $this->assertEqual( true, $this->lockTest($file)); $lock->lock(); $lock->unlock(); } public function testRelock() { // Trying to lock a file twice should throw an exception. $file = new TempFile(); $lock = PhutilFileLock::newForPath($file); $lock->lock(); $caught = null; try { $lock->lock(); } catch (Exception $ex) { $caught = $ex; } $this->assertEqual( true, ($caught instanceof Exception)); } public function testExcessiveUnlock() { // Trying to unlock a file twice should throw an exception. $file = new TempFile(); $lock = PhutilFileLock::newForPath($file); $lock->lock(); $lock->unlock(); $caught = null; try { $lock->unlock(); } catch (Exception $ex) { $caught = $ex; } $this->assertEqual( true, ($caught instanceof Exception)); } public function testUnlockAll() { // unlockAll() should release all locks. $file = new TempFile(); $lock = PhutilFileLock::newForPath($file); $lock->lock(); $this->assertEqual(false, $this->lockTest($file)); PhutilFileLock::unlockAll(); $this->assertEqual(true, $this->lockTest($file)); // Calling this again shouldn't do anything bad. PhutilFileLock::unlockAll(); $this->assertEqual(true, $this->lockTest($file)); $lock->lock(); $lock->unlock(); } public function testIsLocked() { // isLocked() should report lock status accurately. $file = new TempFile(); $lock = PhutilFileLock::newForPath($file); $this->assertEqual(false, $lock->isLocked()); $lock->lock(); $this->assertEqual(true, $lock->isLocked()); $lock->unlock(); $this->assertEqual(false, $lock->isLocked()); } private function lockTest($file) { list($err) = $this->buildLockFuture('--test', $file)->resolve(); return ($err == 0); } private function holdLock($file) { $future = $this->buildLockFuture('--hold', $file); // We can't return until we're sure the subprocess has had time to acquire // the lock. Since actually testing for the lock would be kind of silly // and guarantee that we loop forever if the locking primitive broke, // watch stdout for a *claim* that it has acquired the lock instead. // Make sure we don't loop forever, no matter how bad things get. $future->setTimeout(30); $buf = ''; while (!$future->isReady()) { list($stdout) = $future->read(); $buf .= $stdout; if (strpos($buf, 'LOCK ACQUIRED') !== false) { return $future; } } throw new Exception("Unable to hold lock in external process!"); } private function buildLockFuture($flags, $file) { $root = dirname(phutil_get_library_root('phutil')); $bin = $root.'/scripts/utils/lock.php'; $future = new ExecFuture('%s %C %s', $bin, $flags, $file); $future->start(); return $future; } } diff --git a/src/filesystem/linesofalarge/__tests__/LinesOfALargeExecFutureTestCase.php b/src/filesystem/linesofalarge/__tests__/LinesOfALargeExecFutureTestCase.php index 98c20a7..7d5d7e7 100644 --- a/src/filesystem/linesofalarge/__tests__/LinesOfALargeExecFutureTestCase.php +++ b/src/filesystem/linesofalarge/__tests__/LinesOfALargeExecFutureTestCase.php @@ -1,79 +1,79 @@ writeAndRead( "cat\ndog\nbird\n", array( "cat", "dog", "bird", )); } public function testExecLargeFile() { $line = "The quick brown fox jumps over the lazy dog."; $n = 100; $this->writeAndRead( str_repeat($line."\n", $n), array_fill(0, $n, $line)); } public function testExecLongLine() { $line = str_repeat('x', 64 * 1024); $this->writeAndRead($line, array($line)); } public function testExecException() { $caught = null; try { $future = new ExecFuture('does-not-exist.exe.sh'); foreach (new LinesOfALargeExecFuture($future) as $line) { // ignore } } catch (Exception $ex) { $caught = $ex; } $this->assertEqual(true, $caught instanceof CommandException); } private function writeAndRead($write, $read) { $future = new ExecFuture('cat'); $future->write($write); $lines = array(); foreach (new LinesOfALargeExecFuture($future) as $line) { $lines[] = $line; } $this->assertEqual( $read, $lines, "Write: ".phutil_utf8_shorten($write, 32)); } } diff --git a/src/filesystem/linesofalarge/__tests__/LinesOfALargeFileTestCase.php b/src/filesystem/linesofalarge/__tests__/LinesOfALargeFileTestCase.php index af0f553..2827593 100644 --- a/src/filesystem/linesofalarge/__tests__/LinesOfALargeFileTestCase.php +++ b/src/filesystem/linesofalarge/__tests__/LinesOfALargeFileTestCase.php @@ -1,115 +1,115 @@ writeAndRead( "abcd", array( "abcd", )); } public function testTerminalDelimiterPresent() { $this->writeAndRead( "bat\ncat\ndog\n", array( "bat", "cat", "dog", )); } public function testTerminalDelimiterAbsent() { $this->writeAndRead( "bat\ncat\ndog", array( "bat", "cat", "dog", )); } public function testChangeDelimiter() { $this->writeAndRead( "bat\1cat\1dog\1", array( "bat", "cat", "dog", ), "\1"); } public function testEmptyLines() { $this->writeAndRead( "\n\nbat\n", array( '', '', 'bat', )); } public function testLargeFile() { $line = "The quick brown fox jumps over the lazy dog."; $n = 100; $this->writeAndRead( str_repeat($line."\n", $n), array_fill(0, $n, $line)); } public function testLongLine() { $line = str_repeat('x', 64 * 1024); $this->writeAndRead($line, array($line)); } public function testReadFailure() { $caught = null; try { $f = new LinesOfALargeFile('/does/not/exist.void'); $f->rewind(); } catch (FilesystemException $ex) { $caught = $ex; } $this->assertEqual(true, $caught instanceof $ex); } private function writeAndRead($write, $read, $delimiter = "\n") { $tmp = new TempFile(); Filesystem::writeFile($tmp, $write); $lines = array(); $iterator = id(new LinesOfALargeFile($tmp))->setDelimiter($delimiter); foreach ($iterator as $line) { $lines[] = $line; } $this->assertEqual( $read, $lines, "Write: ".phutil_utf8_shorten($write, 32)); } } diff --git a/src/future/__tests__/ExecFutureTestCase.php b/src/future/__tests__/ExecFutureTestCase.php index 875ff1c..7f797fc 100644 --- a/src/future/__tests__/ExecFutureTestCase.php +++ b/src/future/__tests__/ExecFutureTestCase.php @@ -1,116 +1,116 @@ write('')->resolvex(); $this->assertEqual('', $stdout); } public function testKeepPipe() { // NOTE: This is mosty testing the semantics of $keep_pipe in write(). list($stdout) = id(new ExecFuture('cat')) ->write('', true) ->start() ->write('x', true) ->write('y', true) ->write('z', false) ->resolvex(); $this->assertEqual('xyz', $stdout); } public function testLargeBuffer() { // NOTE: This is mostly a coverage test to hit branches where we're still // flushing a buffer. $data = str_repeat('x', 1024 * 1024 * 4); list($stdout) = id(new ExecFuture('cat'))->write($data)->resolvex(); $this->assertEqual($data, $stdout); } public function testBufferLimit() { $data = str_repeat('x', 1024 * 1024); list($stdout) = id(new ExecFuture('cat')) ->setStdoutSizeLimit(1024) ->write($data) ->resolvex(); $this->assertEqual(substr($data, 0, 1024), $stdout); } public function testResolveTimeoutTestShouldRunLessThan1Sec() { // NOTE: This tests interactions between the resolve() timeout and the // ExecFuture timeout, which are similar but not identical. $future = id(new ExecFuture('sleep 32000'))->start(); $future->setTimeout(32000); // We expect this to return in 0.01s. $result = $future->resolve(0.01); $this->assertEqual($result, null); // We expect this to now force the time out / kill immediately. If we don't // do this, we'll hang when exiting until our subprocess exits (32000 // seconds!) $future->setTimeout(0.01); $future->resolve(); } public function testTimeoutTestShouldRunLessThan1Sec() { // NOTE: This is partly testing that we choose appropriate select wait // times; this test should run for significantly less than 1 second. $future = new ExecFuture('sleep 32000'); list($err) = $future->setTimeout(0.01)->resolve(); $this->assertEqual(true, $err > 0); $this->assertEqual(true, $future->getWasKilledByTimeout()); } public function testMultipleTimeoutsTestShouldRunLessThan1Sec() { $futures = array(); for ($ii = 0; $ii < 4; $ii++) { $futures[] = id(new ExecFuture('sleep 32000'))->setTimeout(0.01); } foreach (Futures($futures) as $future) { list ($err) = $future->resolve(); $this->assertEqual(true, $err > 0); $this->assertEqual(true, $future->getWasKilledByTimeout()); } } } diff --git a/src/future/__tests__/FutureIteratorTestCase.php b/src/future/__tests__/FutureIteratorTestCase.php index 9d638f4..77a6d78 100644 --- a/src/future/__tests__/FutureIteratorTestCase.php +++ b/src/future/__tests__/FutureIteratorTestCase.php @@ -1,42 +1,42 @@ limit(2); $results = array(); foreach ($iterator as $future) { if ($future === $future1) { $iterator->addFuture($future2); } $results[] = $future->resolve(); } $this->assertEqual(2, count($results)); } } diff --git a/src/parser/__tests__/PhutilJSONTestCase.php b/src/infrastructure/testing/PhutilTestCase.php similarity index 62% copy from src/parser/__tests__/PhutilJSONTestCase.php copy to src/infrastructure/testing/PhutilTestCase.php index f1dc878..7fd4232 100644 --- a/src/parser/__tests__/PhutilJSONTestCase.php +++ b/src/infrastructure/testing/PhutilTestCase.php @@ -1,40 +1,29 @@ assertEqual( - $expect, - $serializer->encodeFormatted(array('x' => array())), - 'Empty arrays should serialize as [], not {}.'); + protected function getLink($method) { + $libphutil_project = 'PHID-APRJ-8d75d09d9c1e15afec3d'; + return + 'https://secure.phabricator.com/diffusion/symbol/'.$method. + '/?lang=php&projects='.$libphutil_project. + '&jump=true&context='.get_class($this); } } diff --git a/src/internationalization/__tests__/PhutilPHTTestCase.php b/src/internationalization/__tests__/PhutilPHTTestCase.php index 86f0c9a..21a278c 100644 --- a/src/internationalization/__tests__/PhutilPHTTestCase.php +++ b/src/internationalization/__tests__/PhutilPHTTestCase.php @@ -1,116 +1,116 @@ assertEqual('beer', pht('beer')); $this->assertEqual('1 beer(s)', pht('%d beer(s)', 1)); PhutilTranslator::getInstance()->addTranslations( array( '%d beer(s)' => array('%d beer', '%d beers'), )); $this->assertEqual('1 beer', pht('%d beer(s)', 1)); PhutilTranslator::getInstance()->setLanguage('cs'); PhutilTranslator::getInstance()->addTranslations( array( '%d beer(s)' => array('%d pivo', '%d piva', '%d piv'), )); $this->assertEqual('5 piv', pht('%d beer(s)', 5)); } public function getDateTranslations() { // The only purpose of this function is to provide a static list of // translations which can come from PhutilTranslator::translateDate() to // allow translation extractor getting them. return array( 'D' => array( pht('Sun'), pht('Mon'), pht('Tue'), pht('Wed'), pht('Thu'), pht('Fri'), pht('Sat'), ), 'l' => array( pht('Sunday'), pht('Monday'), pht('Tuesday'), pht('Wednesday'), pht('Thursday'), pht('Friday'), pht('Saturday'), ), 'S' => array( pht('st'), pht('nd'), pht('rd'), pht('th'), ), 'F' => array( pht('January'), pht('February'), pht('March'), pht('April'), pht('May'), pht('June'), pht('July'), pht('August'), pht('September'), pht('October'), pht('November'), pht('December'), ), 'M' => array( pht('Jan'), pht('Feb'), pht('Mar'), pht('Apr'), pht('May'), pht('Jun'), pht('Jul'), pht('Aug'), pht('Sep'), pht('Oct'), pht('Nov'), pht('Dec'), ), 'a' => array( pht('am'), pht('pm'), ), 'A' => array( pht('AM'), pht('PM'), ), ); } } diff --git a/src/internationalization/__tests__/PhutilTranslatorTestCase.php b/src/internationalization/__tests__/PhutilTranslatorTestCase.php index 3641a89..04bdb74 100644 --- a/src/internationalization/__tests__/PhutilTranslatorTestCase.php +++ b/src/internationalization/__tests__/PhutilTranslatorTestCase.php @@ -1,165 +1,165 @@ addTranslations( array( '%d line(s)' => array('%d line', '%d lines'), '%d char(s) on %d row(s)' => array( array('%d char on %d row', '%d char on %d rows'), array('%d chars on %d row', '%d chars on %d rows'), ), )); $this->assertEqual('line', $translator->translate('line')); $this->assertEqual('param', $translator->translate('%s', 'param')); $this->assertEqual('0 lines', $translator->translate('%d line(s)', 0)); $this->assertEqual('1 line', $translator->translate('%d line(s)', 1)); $this->assertEqual('2 lines', $translator->translate('%d line(s)', 2)); $this->assertEqual( '1 char on 1 row', $translator->translate('%d char(s) on %d row(s)', 1, 1)); $this->assertEqual( '5 chars on 2 rows', $translator->translate('%d char(s) on %d row(s)', 5, 2)); $this->assertEqual('1 beer(s)', $translator->translate('%d beer(s)', 1)); } public function testCzech() { $translator = new PhutilTranslator(); $translator->setLanguage('cs'); $translator->addTranslations( array( '%d beer(s)' => array('%d pivo', '%d piva', '%d piv'), )); $this->assertEqual('0 piv', $translator->translate('%d beer(s)', 0)); $this->assertEqual('1 pivo', $translator->translate('%d beer(s)', 1)); $this->assertEqual('2 piva', $translator->translate('%d beer(s)', 2)); $this->assertEqual('5 piv', $translator->translate('%d beer(s)', 5)); $this->assertEqual('1 line(s)', $translator->translate('%d line(s)', 1)); } public function testPerson() { $translator = new PhutilTranslator(); $translator->setLanguage('cs'); $translator->addTranslations( array( '%s wrote.' => array('%s napsal.', '%s napsala.'), )); $person = new PhutilPersonTest(); $this->assertEqual( 'Test () napsal.', $translator->translate('%s wrote.', $person)); $person->setSex(PhutilPerson::SEX_MALE); $this->assertEqual( 'Test (m) napsal.', $translator->translate('%s wrote.', $person)); $person->setSex(PhutilPerson::SEX_FEMALE); $this->assertEqual( 'Test (f) napsala.', $translator->translate('%s wrote.', $person)); } public function testTranslateDate() { $date = new DateTime('2012-06-21'); $translator = new PhutilTranslator(); $this->assertEqual('June', $translator->translateDate('F', $date)); $this->assertEqual('June 21', $translator->translateDate('F d', $date)); $this->assertEqual('F', $translator->translateDate('\F', $date)); $translator->addTranslations( array( 'June' => 'correct', '21' => 'wrong', 'F' => 'wrong' )); $this->assertEqual('correct', $translator->translateDate('F', $date)); $this->assertEqual('correct 21', $translator->translateDate('F d', $date)); $this->assertEqual('F', $translator->translateDate('\F', $date)); } public function testSetInstance() { PhutilTranslator::setInstance(new PhutilTranslator()); $original = PhutilTranslator::getInstance(); $this->assertEqual('color', pht('color')); $british = new PhutilTranslator(); $british->addTranslations( array( 'color' => 'colour', )); PhutilTranslator::setInstance($british); $this->assertEqual('colour', pht('color')); PhutilTranslator::setInstance($original); $this->assertEqual('color', pht('color')); } public function testValidateTranslation() { $tests = array( 'a < 2' => array( 'a < 2' => true, 'b < 3' => true, '2 > a' => false, 'a<2' => false, ), 'We win' => array( 'We win' => true, 'We win' => true, // false positive 'We win' => false, 'We win' => false, ), 'We win & triumph' => array( 'We triumph & win' => true, 'We win and triumph' => false, ), 'beer' => array( 'pivo' => true, 'b<>r' => false, 'b&&r' => false, ), ); $translator = new PhutilTranslator(); foreach ($tests as $original => $translations) { foreach ($translations as $translation => $expect) { $valid = ($expect ? "valid" : "invalid"); $this->assertEqual( $expect, $translator->validateTranslation($original, $translation), "'{$original}' should be {$valid} with '{$translation}'."); } } } } diff --git a/src/lexer/__tests__/PhutilPHPFragmentLexerTestCase.php b/src/lexer/__tests__/PhutilPHPFragmentLexerTestCase.php index 20a307e..2a65f31 100644 --- a/src/lexer/__tests__/PhutilPHPFragmentLexerTestCase.php +++ b/src/lexer/__tests__/PhutilPHPFragmentLexerTestCase.php @@ -1,305 +1,305 @@ runLexer($file, $data); } } private function runLexer($file, $data) { $lexer = new PhutilPHPFragmentLexer(); $caught = null; $tokens = null; try { $tokens = $lexer->getTokens($data); } catch (Exception $ex) { $caught = $ex; } switch ($file) { case 'basics.txt': $this->assertEqual(null, $caught); $this->assertEqual( array( array('cp', 'assertEqual(null, $caught); $this->assertEqual( array( array('cp', 'assertEqual(null, $caught); $tokens = $lexer->mergeTokens($tokens); $this->assertEqual( array( array('cp', '', null), array(null, "\n\nd\n", null), ), $tokens, $file); break; case 'extendsimplements.txt': $this->assertEqual(null, $caught); $this->assertEqual( array( array('cp', 'assertEqual(null, $caught); $this->assertEqual( array( array('cp', 'assertEqual(null, $caught); $this->assertEqual( array( array('cp', 'assertEqual(null, $caught); $this->assertEqual( array( array('cp', 'assertEqual(null, $caught); $this->assertEqual( array( array('cp', 'assertEqual( phutil_render_tag('x'), phutil_render_tag('x', array())); $this->assertEqual( phutil_render_tag('x', array()), phutil_render_tag('x', array(), null)); } public function testTagEmpty() { $this->assertEqual( '', phutil_render_tag('x', array(), null)); $this->assertEqual( '', phutil_render_tag('x', array(), '')); } public function testTagBasics() { $this->assertEqual( '', phutil_render_tag('x')); $this->assertEqual( 'y', phutil_render_tag('x', array(), 'y')); } public function testTagAttributes() { $this->assertEqual( 'y', phutil_render_tag('x', array('u' => 'v'), 'y')); $this->assertEqual( '', phutil_render_tag('x', array('u' => 'v'))); } public function testTagEscapes() { $this->assertEqual( '', phutil_render_tag('x', array('u' => '<'))); $this->assertEqual( '', phutil_render_tag('x', array(), phutil_render_tag('y'))); } public function testTagNullAttribute() { $this->assertEqual( '', phutil_render_tag('x', array('y' => null))); } public function testTagJavascriptProtocolRejection() { $hrefs = array( 'javascript:alert(1)' => true, 'JAVASCRIPT:alert(1)' => true, ' javascript:alert(1)' => true, '/' => false, '/path/to/stuff/' => false, '' => false, 'http://example.com/' => false, '#' => false, ); foreach (array(true, false) as $use_uri) { foreach ($hrefs as $href => $expect) { if ($use_uri) { $href = new PhutilURI($href); } $caught = null; try { phutil_render_tag('a', array('href' => $href), 'click for candy'); } catch (Exception $ex) { $caught = $ex; } $this->assertEqual( $expect, $caught instanceof Exception, "Rejected href: {$href}"); } } } public function testURIEscape() { $this->assertEqual( '%2B/%20%3F%23%26%3A%21xyz%25', phutil_escape_uri('+/ ?#&:!xyz%')); } public function testURIPathComponentEscape() { $this->assertEqual( 'a%252Fb', phutil_escape_uri_path_component('a/b')); $str = ''; for ($ii = 0; $ii <= 255; $ii++) { $str .= chr($ii); } $this->assertEqual( $str, phutil_unescape_uri_path_component( rawurldecode( // Simulates webserver. phutil_escape_uri_path_component($str)))); } public function testHsprintf() { $this->assertEqual( '
<3
', hsprintf('
%s
', '<3')); } } diff --git a/src/markup/engine/__tests__/PhutilRemarkupEngineTestCase.php b/src/markup/engine/__tests__/PhutilRemarkupEngineTestCase.php index 8880002..da89ea3 100644 --- a/src/markup/engine/__tests__/PhutilRemarkupEngineTestCase.php +++ b/src/markup/engine/__tests__/PhutilRemarkupEngineTestCase.php @@ -1,102 +1,102 @@ markupText($root.$file); } } private function markupText($markup_file) { $contents = Filesystem::readFile($markup_file); $file = basename($markup_file); $parts = explode("\n~~~~~~~~~~\n", $contents); $this->assertEqual(2, count($parts)); list($input_remarkup, $expected_output) = $parts; switch ($file) { case 'raw-escape.txt': // NOTE: Here, we want to test PhutilRemarkupRuleEscapeRemarkup and // PhutilRemarkupBlockStorage, which are triggered by "\1". In the // test, "~" is used as a placeholder for "\1" since it's hard to type // "\1". $input_remarkup = str_replace("~", "\1", $input_remarkup); $expected_output = str_replace("~", "\1", $expected_output); break; } $engine = $this->buildNewTestEngine(); $actual_output = $engine->markupText($input_remarkup); $this->assertEqual( $expected_output, $actual_output, "Failed to markup file '{$file}'."); } private function buildNewTestEngine() { $engine = new PhutilRemarkupEngine(); $engine->setConfig( 'uri.allowed-protocols', array( 'http' => true, )); $rules = array(); $rules[] = new PhutilRemarkupRuleEscapeRemarkup(); $rules[] = new PhutilRemarkupRuleMonospace(); $rules[] = new PhutilRemarkupRuleDocumentLink(); $rules[] = new PhutilRemarkupRuleHyperlink(); $rules[] = new PhutilRemarkupRuleEscapeHTML(); $rules[] = new PhutilRemarkupRuleBold(); $rules[] = new PhutilRemarkupRuleItalic(); $rules[] = new PhutilRemarkupRuleDel(); $blocks = array(); $blocks[] = new PhutilRemarkupEngineRemarkupHeaderBlockRule(); $blocks[] = new PhutilRemarkupEngineRemarkupListBlockRule(); $blocks[] = new PhutilRemarkupEngineRemarkupCodeBlockRule(); $blocks[] = new PhutilRemarkupEngineRemarkupNoteBlockRule(); $blocks[] = new PhutilRemarkupEngineRemarkupDefaultBlockRule(); foreach ($blocks as $block) { if (!($block instanceof PhutilRemarkupEngineRemarkupCodeBlockRule)) { $block->setMarkupRules($rules); } } $engine->setBlockRules($blocks); return $engine; } } diff --git a/src/markup/syntax/engine/__tests__/PhutilDefaultSyntaxHighlighterEngineTestCase.php b/src/markup/syntax/engine/__tests__/PhutilDefaultSyntaxHighlighterEngineTestCase.php index 1ac02ca..287914c 100644 --- a/src/markup/syntax/engine/__tests__/PhutilDefaultSyntaxHighlighterEngineTestCase.php +++ b/src/markup/syntax/engine/__tests__/PhutilDefaultSyntaxHighlighterEngineTestCase.php @@ -1,43 +1,43 @@ 'php', '/x.php' => 'php', 'x.y.php' => 'php', '/x.y/z.php' => 'php', '/x.php/' => null, ); $engine = new PhutilDefaultSyntaxHighlighterEngine(); foreach ($names as $path => $language) { $detect = $engine->getLanguageFromFilename($path); $this->assertEqual($language, $detect, 'Language detect for '.$path); } } } diff --git a/src/markup/syntax/highlighter/__tests__/PhutilPHPFragmentLexerHighlighterTestCase.php b/src/markup/syntax/highlighter/__tests__/PhutilPHPFragmentLexerHighlighterTestCase.php index 1e7fd84..0926483 100644 --- a/src/markup/syntax/highlighter/__tests__/PhutilPHPFragmentLexerHighlighterTestCase.php +++ b/src/markup/syntax/highlighter/__tests__/PhutilPHPFragmentLexerHighlighterTestCase.php @@ -1,45 +1,44 @@ setConfig('language', 'php'); $highlighter->setConfig('lexer', new PhutilPHPFragmentLexer()); $path = dirname(__FILE__).'/phpfragment/'; foreach (Filesystem::listDirectory($path, $include_hidden = false) as $f) { if (preg_match('/.test$/', $f)) { $expect = preg_replace('/.test$/', '.expect', $f); $source = Filesystem::readFile($path.'/'.$f); $this->assertEqual( Filesystem::readFile($path.'/'.$expect), $highlighter->getHighlightFuture($source)->resolve(), $f); } } } } diff --git a/src/markup/syntax/highlighter/__tests__/PhutilXHPASTSyntaxHighlighterTestCase.php b/src/markup/syntax/highlighter/__tests__/PhutilXHPASTSyntaxHighlighterTestCase.php index ed6029c..c2d0960 100644 --- a/src/markup/syntax/highlighter/__tests__/PhutilXHPASTSyntaxHighlighterTestCase.php +++ b/src/markup/syntax/highlighter/__tests__/PhutilXHPASTSyntaxHighlighterTestCase.php @@ -1,47 +1,46 @@ getHighlightFuture($source); return $future->resolve(); } private function read($file) { $path = dirname(__FILE__).'/xhpast/'.$file; return Filesystem::readFile($path); } public function testBuiltinClassnames() { $this->assertEqual( $this->read('builtin-classname.expect'), $this->highlight($this->read('builtin-classname.source')), 'Builtin classnames should not be marked as linkable symbols.'); $this->assertEqual( $this->read('trailing-comment.expect'), $this->highlight($this->read('trailing-comment.source')), 'Trailing comments should not be dropped.'); } } diff --git a/src/parser/__tests__/PhutilDocblockParserTestCase.php b/src/parser/__tests__/PhutilDocblockParserTestCase.php index 1eca27b..adc87f3 100644 --- a/src/parser/__tests__/PhutilDocblockParserTestCase.php +++ b/src/parser/__tests__/PhutilDocblockParserTestCase.php @@ -1,134 +1,134 @@ parseDocblock($root.$file); } } private function parseDocblock($doc_file) { $contents = Filesystem::readFile($doc_file); $file = basename($doc_file); $parser = new PhutilDocblockParser(); list($docblock, $specials) = $parser->parse($contents); switch ($file) { case 'embedded-specials.docblock': $this->assertEqual(array(), $specials); $this->assertEqual( "So long as a @special does not appear at the beginning of a line,\n". "it is parsed as normal text.", $docblock); break; case 'indented-block.docblock': $this->assertEqual(array(), $specials); $this->assertEqual( "Cozy lummox gives smart squid who asks for job pen.", $docblock); break; case 'indented-text.docblock': $this->assertEqual(array(), $specials); $this->assertEqual( "Cozy lummox gives smart squid who asks for job pen.", $docblock); break; case 'multiline-special.docblock': $this->assertEqual( array( 'special' => "x y z", ), $specials); $this->assertEqual( "", $docblock); break; case 'multi-specials.docblock': $this->assertEqual( array( 'special' => "north\nsouth", ), $specials); $this->assertEqual( "", $docblock); break; case 'specials.docblock': $this->assertEqual( array( 'type' => 'type', 'task' => 'task', ), $specials); $this->assertEqual( "", $docblock); break; case 'linebreak-breaks-specials.docblock': $this->assertEqual( array( 'title' => 'title', ), $specials); $this->assertEqual( "This is normal text, not part of the @title.", $docblock); break; case 'specials-with-hyphen.docblock': $this->assertEqual( array( 'repeat-hyphen' => "a\nb", 'multiline-hyphen' => "mmm nnn", 'normal-hyphen' => "x", ), $specials); break; case 'indented-specials.docblock': $this->assertEqual( array( 'title' => 'sendmail', ), $specials); break; case 'flag-specials.docblock': $this->assertEqual( "stuff above\n\nstuff in the middle\n\nstuff below", $docblock); $this->assertEqual( array( 'flag' => true, 'stuff' => true, 'zebra' => true, 'apple' => true, ), $specials); break; default: throw new Exception("No test case to handle file '{$file}'!"); } } } diff --git a/src/parser/__tests__/PhutilEmailAddressTestCase.php b/src/parser/__tests__/PhutilEmailAddressTestCase.php index b13e22d..886a57c 100644 --- a/src/parser/__tests__/PhutilEmailAddressTestCase.php +++ b/src/parser/__tests__/PhutilEmailAddressTestCase.php @@ -1,113 +1,113 @@ '); $this->assertEqual( 'Abraham Lincoln', $email->getDisplayName()); $this->assertEqual( 'alincoln', $email->getLocalPart()); $this->assertEqual( 'logcabin.com', $email->getDomainName()); $this->assertEqual( 'alincoln@logcabin.com', $email->getAddress()); $email = new PhutilEmailAddress('alincoln@logcabin.com'); $this->assertEqual( null, $email->getDisplayName()); $this->assertEqual( 'alincoln', $email->getLocalPart()); $this->assertEqual( 'logcabin.com', $email->getDomainName()); $this->assertEqual( 'alincoln@logcabin.com', $email->getAddress()); $email = new PhutilEmailAddress('"Abraham" '); $this->assertEqual( 'Abraham', $email->getDisplayName()); $this->assertEqual( 'alincoln', $email->getLocalPart()); $this->assertEqual( 'logcabin.com', $email->getDomainName()); $this->assertEqual( 'alincoln@logcabin.com', $email->getAddress()); $email = new PhutilEmailAddress(' alincoln@logcabin.com '); $this->assertEqual( null, $email->getDisplayName()); $this->assertEqual( 'alincoln', $email->getLocalPart()); $this->assertEqual( 'logcabin.com', $email->getDomainName()); $this->assertEqual( 'alincoln@logcabin.com', $email->getAddress()); $email = new PhutilEmailAddress('alincoln'); $this->assertEqual( null, $email->getDisplayName()); $this->assertEqual( 'alincoln', $email->getLocalPart()); $this->assertEqual( null, $email->getDomainName()); $this->assertEqual( 'alincoln', $email->getAddress()); $email = new PhutilEmailAddress('alincoln '); $this->assertEqual( 'alincoln', $email->getDisplayName()); $this->assertEqual( 'alincoln at logcabin dot com', $email->getLocalPart()); $this->assertEqual( null, $email->getDomainName()); $this->assertEqual( 'alincoln at logcabin dot com', $email->getAddress()); } } diff --git a/src/parser/__tests__/PhutilGitURITestCase.php b/src/parser/__tests__/PhutilGitURITestCase.php index 253f6c6..b36d5ba 100644 --- a/src/parser/__tests__/PhutilGitURITestCase.php +++ b/src/parser/__tests__/PhutilGitURITestCase.php @@ -1,41 +1,41 @@ assertEqual('git', $uri->getUser()); $this->assertEqual('host.com', $uri->getDomain()); $this->assertEqual('path/to/something', $uri->getPath()); $this->assertEqual('git@host.com:path/to/something', (string)$uri); $uri = new PhutilGitURI('host.com:path/to/something'); $this->assertEqual('', $uri->getUser()); $this->assertEqual('host.com', $uri->getDomain()); $this->assertEqual('path/to/something', $uri->getPath()); $this->assertEqual('host.com:path/to/something', (string)$uri); } } diff --git a/src/parser/__tests__/PhutilJSONTestCase.php b/src/parser/__tests__/PhutilJSONTestCase.php index f1dc878..e6712d5 100644 --- a/src/parser/__tests__/PhutilJSONTestCase.php +++ b/src/parser/__tests__/PhutilJSONTestCase.php @@ -1,40 +1,40 @@ assertEqual( $expect, $serializer->encodeFormatted(array('x' => array())), 'Empty arrays should serialize as [], not {}.'); } } diff --git a/src/parser/__tests__/PhutilLanguageGuesserTestCase.php b/src/parser/__tests__/PhutilLanguageGuesserTestCase.php index 440f4ae..014ac66 100644 --- a/src/parser/__tests__/PhutilLanguageGuesserTestCase.php +++ b/src/parser/__tests__/PhutilLanguageGuesserTestCase.php @@ -1,42 +1,42 @@ assertEqual( $expect, PhutilLanguageGuesser::guessLanguage($source), "Guessed language for '{$test}'."); } } } diff --git a/src/parser/__tests__/PhutilSimpleOptionsTestCase.php b/src/parser/__tests__/PhutilSimpleOptionsTestCase.php index 3a89e25..946008e 100644 --- a/src/parser/__tests__/PhutilSimpleOptionsTestCase.php +++ b/src/parser/__tests__/PhutilSimpleOptionsTestCase.php @@ -1,102 +1,102 @@ array(), // Basic parsing. 'legs=4' => array('legs' => '4'), 'legs=4,eyes=2' => array('legs' => '4', 'eyes' => '2'), // Repeated keys mean last specification wins. 'legs=4,legs=3' => array('legs' => '3'), // Keys with no value should map to true. 'flag' => array('flag' => true), 'legs=4,flag' => array('legs' => '4', 'flag' => true), // Spaces should be ignored. ' flag ' => array('flag' => true), ' legs = 4 , eyes = 2' => array('legs' => '4', 'eyes' => '2'), // Case should be ignored. 'LEGS=4' => array('legs' => '4'), 'legs=4, LEGS=4' => array('legs' => '4'), // Empty values should be absent. 'legs=' => array(), 'legs=4,legs=,eyes=2' => array('eyes' => '2'), // Strings like this should not parse as simpleoptions. 'SELECT id, name, size FROM table' => array(), ); foreach ($map as $string => $expect) { $this->assertEqual( $expect, PhutilSimpleOptions::parse($string), "Correct parse of '{$string}'"); } } public function testSimpleOptionsUnparse() { $map = array( '' => array(), 'legs=4' => array('legs' => '4'), 'legs=4, eyes=2' => array('legs' => '4', 'eyes' => '2'), 'eyes=2, legs=4' => array('eyes' => '2', 'legs' => '4'), 'legs=4, head' => array('legs' => '4', 'head' => true), 'eyes=2' => array('legs' => '', 'eyes' => '2'), ); foreach ($map as $expect => $dict) { $this->assertEqual( $expect, PhutilSimpleOptions::unparse($dict), "Correct unparse of ".print_r($dict, true)); } $bogus = array( array('LEGS' => true), array('LEGS' => 4), array('!' => '!'), array('' => '2'), ); foreach ($bogus as $bad_input) { $caught = null; try { PhutilSimpleOptions::unparse($bad_input); } catch (Exception $ex) { $caught = $ex; } $this->assertEqual( true, $caught instanceof Exception, "Correct throw on unparse of bad input."); } } } diff --git a/src/parser/__tests__/PhutilURITestCase.php b/src/parser/__tests__/PhutilURITestCase.php index 157e0eb..f86ba04 100644 --- a/src/parser/__tests__/PhutilURITestCase.php +++ b/src/parser/__tests__/PhutilURITestCase.php @@ -1,65 +1,65 @@ assertEqual('http', $uri->getProtocol(), 'protocol'); $this->assertEqual('user', $uri->getUser(), 'user'); $this->assertEqual('pass', $uri->getPass(), 'pass'); $this->assertEqual('host', $uri->getDomain(), 'domain'); $this->assertEqual('99', $uri->getPort(), 'port'); $this->assertEqual('/path/', $uri->getPath(), 'path'); $this->assertEqual( array( 'query' => 'value', ), $uri->getQueryParams(), 'query params'); $this->assertEqual('fragment', $uri->getFragment(), 'fragment'); $this->assertEqual( 'http://user:pass@host:99/path/?query=value#fragment', (string)$uri, 'uri'); $uri = new PhutilURI('ssh://git@example.com/example/example.git'); $this->assertEqual('ssh', $uri->getProtocol(), 'protocol'); $this->assertEqual('git', $uri->getUser(), 'user'); $this->assertEqual('', $uri->getPass(), 'pass'); $this->assertEqual('example.com', $uri->getDomain(), 'domain'); $this->assertEqual('', $uri->getPort(), 'port'); $this->assertEqual('/example/example.git', $uri->getPath(), 'path'); $this->assertEqual(array(), $uri->getQueryParams(), 'query params'); $this->assertEqual('', $uri->getFragment(), 'fragment'); $this->assertEqual( 'ssh://git@example.com/example/example.git', (string)$uri, 'uri'); } } diff --git a/src/parser/argument/__tests__/PhutilArgumentParserTestCase.php b/src/parser/argument/__tests__/PhutilArgumentParserTestCase.php index 44940c8..62d82be 100644 --- a/src/parser/argument/__tests__/PhutilArgumentParserTestCase.php +++ b/src/parser/argument/__tests__/PhutilArgumentParserTestCase.php @@ -1,425 +1,425 @@ 'flag', )); $args = new PhutilArgumentParser(array('bin')); $args->parseFull($specs); $this->assertEqual(false, $args->getArg('flag')); $args = new PhutilArgumentParser(array('bin', '--flag')); $args->parseFull($specs); $this->assertEqual(true, $args->getArg('flag')); } public function testWildcards() { $specs = array( array( 'name' => 'flag', ), array( 'name' => 'files', 'wildcard' => true, ), ); $args = new PhutilArgumentParser(array('bin', '--flag', 'a', 'b')); $args->parseFull($specs); $this->assertEqual(true, $args->getArg('flag')); $this->assertEqual( array('a', 'b'), $args->getArg('files')); $caught = null; try { $args = new PhutilArgumentParser(array('bin', '--derp', 'a', 'b')); $args->parseFull($specs); } catch (PhutilArgumentUsageException $ex) { $caught = $ex; } $this->assertEqual(true, $caught instanceof Exception); $args = new PhutilArgumentParser(array('bin', '--', '--derp', 'a', 'b')); $args->parseFull($specs); $this->assertEqual( array('--derp', 'a', 'b'), $args->getArg('files')); } public function testPartialParse() { $specs = array( array( 'name' => 'flag', ), ); $args = new PhutilArgumentParser(array('bin', 'a', '--flag', '--', 'b')); $args->parsePartial($specs); $this->assertEqual( array('a', '--', 'b'), $args->getUnconsumedArgumentVector()); } public function testBadArg() { $args = new PhutilArgumentParser(array('bin')); $args->parseFull(array()); $caught = null; try { $args->getArg('flag'); } catch (PhutilArgumentSpecificationException $ex) { $caught = $ex; } $this->assertEqual(true, $caught instanceof Exception); } public function testDuplicateNames() { $args = new PhutilArgumentParser(array('bin')); $caught = null; try { $args->parseFull( array( array( 'name' => 'x', ), array( 'name' => 'x', ))); } catch (PhutilArgumentSpecificationException $ex) { $caught = $ex; } $this->assertEqual(true, $caught instanceof Exception); } public function testDuplicateNamesWithParsePartial() { $args = new PhutilArgumentParser(array('bin')); $caught = null; try { $args->parsePartial( array( array( 'name' => 'x', ))); $args->parsePartial( array( array( 'name' => 'x', ))); } catch (PhutilArgumentSpecificationException $ex) { $caught = $ex; } $this->assertEqual(true, $caught instanceof Exception); } public function testDuplicateShortAliases() { $args = new PhutilArgumentParser(array('bin')); $caught = null; try { $args->parseFull( array( array( 'name' => 'x', 'short' => 'x', ), array( 'name' => 'y', 'short' => 'x', ))); } catch (PhutilArgumentSpecificationException $ex) { $caught = $ex; } $this->assertEqual(true, $caught instanceof Exception); } public function testDuplicateWildcards() { $args = new PhutilArgumentParser(array('bin')); $caught = null; try { $args->parseFull( array( array( 'name' => 'x', 'wildcard' => true, ), array( 'name' => 'y', 'wildcard' => true, ))); } catch (PhutilArgumentSpecificationException $ex) { $caught = $ex; } $this->assertEqual(true, $caught instanceof Exception); } public function testDuplicatePartialWildcards() { $args = new PhutilArgumentParser(array('bin')); $caught = null; try { $args->parsePartial( array( array( 'name' => 'x', 'wildcard' => true, ), )); $args->parsePartial( array( array( 'name' => 'y', 'wildcard' => true, ), )); } catch (PhutilArgumentSpecificationException $ex) { $caught = $ex; } $this->assertEqual(true, $caught instanceof Exception); } public function testConflictSpecificationWithUnrecognizedArg() { $args = new PhutilArgumentParser(array('bin')); $caught = null; try { $args->parseFull( array( array( 'name' => 'x', 'conflicts' => array( 'y' => true, ), ), )); } catch (PhutilArgumentSpecificationException $ex) { $caught = $ex; } $this->assertEqual(true, $caught instanceof Exception); } public function testConflictSpecificationWithSelf() { $args = new PhutilArgumentParser(array('bin')); $caught = null; try { $args->parseFull( array( array( 'name' => 'x', 'conflicts' => array( 'x' => true, ), ), )); } catch (PhutilArgumentSpecificationException $ex) { $caught = $ex; } $this->assertEqual(true, $caught instanceof Exception); } public function testUnrecognizedFlag() { $args = new PhutilArgumentParser(array('bin', '--flag')); $caught = null; try { $args->parseFull(array()); } catch (PhutilArgumentUsageException $ex) { $caught = $ex; } $this->assertEqual(true, $caught instanceof Exception); } public function testDuplicateFlag() { $args = new PhutilArgumentParser(array('bin', '--flag', '--flag')); $caught = null; try { $args->parseFull( array( array( 'name' => 'flag', ), )); } catch (PhutilArgumentUsageException $ex) { $caught = $ex; } $this->assertEqual(true, $caught instanceof Exception); } public function testMissingParameterValue() { $args = new PhutilArgumentParser(array('bin', '--with')); $caught = null; try { $args->parseFull( array( array( 'name' => 'with', 'param' => 'stuff', ), )); } catch (PhutilArgumentUsageException $ex) { $caught = $ex; } $this->assertEqual(true, $caught instanceof Exception); } public function testExtraParameterValue() { $args = new PhutilArgumentParser(array('bin', '--true=apple')); $caught = null; try { $args->parseFull( array( array( 'name' => 'true', ), )); } catch (PhutilArgumentUsageException $ex) { $caught = $ex; } $this->assertEqual(true, $caught instanceof Exception); } public function testConflictParameterValue() { $args = new PhutilArgumentParser(array('bin', '--true', '--false')); $caught = null; try { $args->parseFull( array( array( 'name' => 'true', 'conflicts' => array( 'false' => true, ), ), array( 'name' => 'false', 'conflicts' => array( 'true' => true, ), ), )); } catch (PhutilArgumentUsageException $ex) { $caught = $ex; } $this->assertEqual(true, $caught instanceof Exception); } public function testParameterValues() { $specs = array( array( 'name' => 'a', 'param' => 'value', ), array( 'name' => 'b', 'param' => 'value', ), array( 'name' => 'cee', 'short' => 'c', 'param' => 'value', ), array( 'name' => 'dee', 'short' => 'd', 'param' => 'value', ), ); $args = new PhutilArgumentParser( array( 'bin', '--a', 'a', '--b=b', '-c', 'c', '-d=d', )); $args->parseFull($specs); $this->assertEqual('a', $args->getArg('a')); $this->assertEqual('b', $args->getArg('b')); $this->assertEqual('c', $args->getArg('cee')); $this->assertEqual('d', $args->getArg('dee')); } public function testStdinValidParameter() { $specs = array( array( 'name' => 'file', 'param' => 'file', ), ); $args = new PhutilArgumentParser( array( 'bin', '-', '--file', '-', )); $args->parsePartial($specs); $this->assertEqual('-', $args->getArg('file')); } public function testRepeatableFlag() { $specs = array( array( 'name' => 'verbose', 'short' => 'v', 'repeat' => true, ), ); $args = new PhutilArgumentParser(array('bin', '-v', '-v', '-v')); $args->parseFull($specs); $this->assertEqual(3, $args->getArg('verbose')); } public function testRepeatableParam() { $specs = array( array( 'name' => 'eat', 'param' => 'fruit', 'repeat' => true, ), ); $args = new PhutilArgumentParser(array( 'bin', '--eat', 'apple', '--eat', 'pear', '--eat=orange', )); $args->parseFull($specs); $this->assertEqual( array('apple', 'pear', 'orange'), $args->getArg('eat')); } } diff --git a/src/parser/argument/__tests__/PhutilArgumentSpecificationTestCase.php b/src/parser/argument/__tests__/PhutilArgumentSpecificationTestCase.php index b8e240c..482e16e 100644 --- a/src/parser/argument/__tests__/PhutilArgumentSpecificationTestCase.php +++ b/src/parser/argument/__tests__/PhutilArgumentSpecificationTestCase.php @@ -1,161 +1,161 @@ true, 'xx' => true, '!' => false, 'XX' => false, '1=' => false, '--' => false, 'no-stuff' => true, '-stuff' => false, ); foreach ($names as $name => $valid) { $caught = null; try { PhutilArgumentSpecification::newQuickSpec( array( 'name' => $name, )); } catch (PhutilArgumentSpecificationException $ex) { $caught = $ex; } $this->assertEqual( !$valid, $caught instanceof Exception, "Arg name '{$name}'."); } } public function testAliases() { $aliases = array( 'a' => true, '1' => true, 'no' => false, '-' => false, '_' => false, ' ' => false, '' => false, ); foreach ($aliases as $alias => $valid) { $caught = null; try { PhutilArgumentSpecification::newQuickSpec( array( 'name' => 'example', 'short' => $alias, )); } catch (PhutilArgumentSpecificationException $ex) { $caught = $ex; } $this->assertEqual( !$valid, $caught instanceof Exception, "Arg alias '{$alias}'."); } } public function testSpecs() { $good_specs = array( array( 'name' => 'verbose', ), array( 'name' => 'verbose', 'short' => 'v', 'help' => 'Derp.', 'param' => 'level', 'default' => 'y', 'conflicts' => array( 'quiet' => true, ), 'wildcard' => false, ), array( 'name' => 'files', 'wildcard' => true, ), ); $bad_specs = array( array( ), array( 'alias' => 'v', ), array( 'name' => 'derp', 'fruit' => 'apple', ), array( 'name' => 'x', 'default' => 'y', ), array( 'name' => 'x', 'param' => 'y', 'default' => 'z', 'repeat' => true, ), array( 'name' => 'x', 'wildcard' => true, 'repeat' => true, ), array( 'name' => 'x', 'param' => 'y', 'wildcard' => true, ), ); $cases = array( array(true, $good_specs), array(false, $bad_specs), ); foreach ($cases as $case) { list($expect, $specs) = $case; foreach ($specs as $spec) { $caught = null; try { PhutilArgumentSpecification::newQuickSpec($spec); } catch (PhutilArgumentSpecificationException $ex) { $caught = $ex; } $this->assertEqual( !$expect, $caught instanceof Exception, "Spec validity for: ".print_r($spec, true)); } } } } diff --git a/src/parser/xhpast/api/__tests__/XHPASTTreeTestCase.php b/src/parser/xhpast/api/__tests__/XHPASTTreeTestCase.php index e8b2219..8964d49 100644 --- a/src/parser/xhpast/api/__tests__/XHPASTTreeTestCase.php +++ b/src/parser/xhpast/api/__tests__/XHPASTTreeTestCase.php @@ -1,149 +1,149 @@ assertEval(1, '1'); $this->assertEval("a", '"a"'); $this->assertEval(-1.1, '-1.1'); $this->assertEval( array('foo', 'bar', -1, +2, -3.4, +4.3, 1e10, 1e-5, -2.3e7), "array('foo', 'bar', -1, +2, -3.4, +4.3, 1e10, 1e-5, -2.3e7)"); $this->assertEval( array(), "array()"); $this->assertEval( array(42 => 7, 'a' => 5, 1, 2, 3, 4, 1 => 'goo'), "array(42 => 7, 'a' => 5, 1, 2, 3, 4, 1 => 'goo')"); $this->assertEval( array('a' => 'a', 'b' => array(1, 2, array(3))), "array('a' => 'a', 'b' => array(1, 2, array(3)))"); $this->assertEval( array(true, false, null), "array(true, false, null)"); // Duplicate keys $this->assertEval( array(0 => '1', 0 => '2'), "array(0 => '1', 0 => '2')"); $this->assertEval('simple string', "'simple string'"); $this->assertEval('42', "'42'"); $this->assertEval(3.1415926, "3.1415926"); $this->assertEval(42, '42'); $this->assertEval( array(2147483648, 2147483647, -2147483648, -2147483647), "array(2147483648, 2147483647, -2147483648, -2147483647)"); $this->assertEval(INF, 'INF'); $this->assertEval(-INF, '-INF'); $this->assertEval(0x1b, '0x1b'); $this->assertEval(0X0A, '0X0A'); // Octal $this->assertEval(010, '010'); $this->assertEval(080, '080'); // Invalid! // Leading 0, but float, not octal. $this->assertEval(0.11e1, '0.11e1'); $this->assertEval(0e1, '0e1'); $this->assertEval(0, '0'); // Static evaluation treats '$' as a literal dollar glyph. $this->assertEval('$asdf', '"$asdf"'); $this->assertEval( '\a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z'. '\1\2\3\4\5\6\7\8\9\0'. '\!\@\#\$\%\^\&\*\(\)'. '\`\~\\\|\[\]\{\}\<\>\,\.\/\?\:\;\-\_\=\+', "'\\a\\b\\c\\d\\e\\f\\g\\h\\i\\j\\k\\l\\m\\n\\o\\p\\q". "\\r\\s\\t\\u\\v\\w\\x\\y\\z". "\\1\\2\\3\\4\\5\\6\\7\\8\\9\\0". "\\!\\@\\#\\$\\%\\^\\&\\*\\(\\)". "\\`\\~\\\\\\|\\[\\]\\{\\}\\<\\>\\,\\.\\/\\?\\:\\;\\-\\_\\=\\+". "'"); $this->assertEval( "\a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z". "\1\2\3\4\5\6\7\8\9\0". "\!\@\#\$\%\^\&\*\(\)". "\`\~\\\|\[\]\{\}\<\>\,\.\/\?\:\;\-\_\=\+", '"\\a\\b\\c\\d\\e\\f\\g\\h\\i\\j\\k\\l\\m\\n\\o\\p\\q'. '\\r\\s\\t\\u\\v\\w\\x\\y\\z'. '\\1\\2\\3\\4\\5\\6\\7\\8\\9\\0'. '\\!\\@\\#\\$\\%\\^\\&\\*\\(\\)'. '\\`\\~\\\\\\|\\[\\]\\{\\}\\<\\>\\,\\.\\/\\?\\:\\;\\-\\_\\=\\+"'); $this->assertEval( '\' "', "'\\' \"'"); $this->assertEval( '\\ \\\\ ', '\'\\\\ \\\\\\\\ \''); $this->assertEval( '\ \\ ', "'\\ \\\\ '"); $this->assertEval( '\x92', '\'\x92\''); $this->assertEval( "\x92", '"\x92"'); $this->assertEval( "\x", '"\x"'); $this->assertEval( "\x1", '"\x1"'); $this->assertEval( "\x000 !", '"\x000 !"'); $this->assertEval( "\x0", '"\x0"'); } private function assertEval($value, $string) { $this->assertEqual( $value, XHPASTTree::evalStaticString($string), $string); } } diff --git a/src/utils/__tests__/AbstractDirectedGraphTestCase.php b/src/utils/__tests__/AbstractDirectedGraphTestCase.php index 77477c3..ebea9be 100644 --- a/src/utils/__tests__/AbstractDirectedGraphTestCase.php +++ b/src/utils/__tests__/AbstractDirectedGraphTestCase.php @@ -1,107 +1,107 @@ array(), ); $cycle = $this->findGraphCycle($graph); $this->assertEqual(null, $cycle, 'Trivial Graph'); } public function testNoncyclicGraph() { $graph = array( 'A' => array('B', 'C'), 'B' => array('D'), 'C' => array(), 'D' => array(), ); $cycle = $this->findGraphCycle($graph); $this->assertEqual(null, $cycle, 'Noncyclic Graph'); } public function testTrivialCyclicGraph() { $graph = array( 'A' => array('A'), ); $cycle = $this->findGraphCycle($graph); $this->assertEqual(array('A', 'A'), $cycle, 'Trivial Cycle'); } public function testCyclicGraph() { $graph = array( 'A' => array('B', 'C'), 'B' => array('D'), 'C' => array('E', 'F'), 'D' => array(), 'E' => array(), 'F' => array('G', 'C'), 'G' => array(), ); $cycle = $this->findGraphCycle($graph); $this->assertEqual(array('A', 'C', 'F', 'C'), $cycle, 'Cyclic Graph'); } public function testNonTreeGraph() { // This graph is non-cyclic, but C is both a child and a grandchild of A. // This is permitted. $graph = array( 'A' => array('B', 'C'), 'B' => array('C'), 'C' => array(), ); $cycle = $this->findGraphCycle($graph); $this->assertEqual(null, $cycle, 'NonTreeGraph'); } public function testEdgeLoadFailure() { $graph = array( 'A' => array('B'), ); $raised = null; try { $this->findGraphCycle($graph); } catch (Exception $ex) { $raised = $ex; } $this->assertEqual( true, (bool)$raised, 'Exception raised by unloadable edges.'); } private function findGraphCycle(array $graph, $seed = 'A', $search = 'A') { $detector = new TestAbstractDirectedGraph(); $detector->setTestData($graph); $detector->addNodes(array_select_keys($graph, array($seed))); $detector->loadGraph(); return $detector->detectCycles($search); } } diff --git a/src/utils/__tests__/PhutilBufferedIteratorTestCase.php b/src/utils/__tests__/PhutilBufferedIteratorTestCase.php index 14460ec..2a5d1cd 100644 --- a/src/utils/__tests__/PhutilBufferedIteratorTestCase.php +++ b/src/utils/__tests__/PhutilBufferedIteratorTestCase.php @@ -1,43 +1,43 @@ setPageSize(3); $iterator->setExampleData($expect); $results = array(); foreach ($iterator as $key => $value) { $results[$key] = $value; } $this->assertEqual( $expect, $results); } } diff --git a/src/utils/__tests__/PhutilUTF8TestCase.php b/src/utils/__tests__/PhutilUTF8TestCase.php index 9fb94e7..b6aecb0 100644 --- a/src/utils/__tests__/PhutilUTF8TestCase.php +++ b/src/utils/__tests__/PhutilUTF8TestCase.php @@ -1,234 +1,234 @@ assertEqual($input, phutil_utf8ize($input)); } public function testUTF8ize_UTF8_ignored() { $input = "\xc3\x9c \xc3\xbc \xe6\x9d\xb1!"; $this->assertEqual($input, phutil_utf8ize($input)); } public function testUTF8ize_LongString_nosegfault() { // For some reason my laptop is segfaulting on long inputs inside // preg_match(). Forestall this craziness in the common case, at least. phutil_utf8ize(str_repeat('x', 1024 * 1024)); $this->assertEqual(true, true); } public function testUTF8ize_invalidUTF8_fixed() { $input = "\xc3 this has \xe6\x9d some invalid utf8 \xe6"; $expect = "\xEF\xBF\xBD this has \xEF\xBF\xBD\xEF\xBF\xBD some invalid utf8 ". "\xEF\xBF\xBD"; $result = phutil_utf8ize($input); $this->assertEqual($expect, $result); } public function testUTF8ize_owl_isCuteAndFerocious() { // This was once a ferocious owl when we used to use "?" as the replacement // character instead of U+FFFD, but now he is sort of not as cute or // ferocious. $input = "M(o\xEE\xFF\xFFo)M"; $expect = "M(o\xEF\xBF\xBD\xEF\xBF\xBD\xEF\xBF\xBDo)M"; $result = phutil_utf8ize($input); $this->assertEqual($expect, $result); } public function testUTF8len() { $strings = array( '' => 0, 'x' => 1, "\xEF\xBF\xBD" => 1, "x\xe6\x9d\xb1y" => 3, "xyz" => 3, 'quack' => 5, ); foreach ($strings as $str => $expect) { $this->assertEqual($expect, phutil_utf8_strlen($str), 'Length of '.$str); } } public function testUTF8v() { $strings = array( '' => array(), 'x' => array('x'), 'quack' => array('q', 'u', 'a', 'c', 'k'), "x\xe6\x9d\xb1y" => array('x', "\xe6\x9d\xb1", 'y'), // TODO: This test does not pass. phutil_utf8v() should merge combining // characters. // "x\xCD\xA0y" => array("x\xCD\xA0", 'y'), ); foreach ($strings as $str => $expect) { $this->assertEqual($expect, phutil_utf8v($str), 'Vector of '.$str); } } public function testUTF8shorten() { $inputs = array( array("1erp derp derp", 9, "", "1erp derp"), array("2erp derp derp", 12, "...", "2erp derp..."), array("derpxderpxderp", 12, "...", "derpxderp..."), array("derp\xE2\x99\x83derpderp", 12, "...", "derp\xE2\x99\x83derp..."), array("", 12, "...", ""), array("derp", 12, "...", "derp"), array("11111", 5, "2222", "11111"), array("111111", 5, "2222", "12222"), array("D1rp. Derp derp.", 7, "...", "D1rp."), array("D2rp. Derp derp.", 5, "...", "D2rp."), array("D3rp. Derp derp.", 4, "...", "D..."), array("D4rp. Derp derp.", 14, "...", "D4rp. Derp..."), array("D5rpderp, derp derp", 16, "...", "D5rpderp..."), array("D6rpderp, derp derp", 17, "...", "D6rpderp, derp..."), // This behavior is maybe a little bad, but it seems mostly reasonable, // at least for latin languages. array("Derp, supercalafragalisticexpialadoshus", 30, "...", "Derp..."), // If a string has only word-break characters in it, we should just cut // it, not produce only the terminal. array("((((((((((", 8, '...', '(((((...'), ); foreach ($inputs as $input) { list($string, $length, $terminal, $expect) = $input; $result = phutil_utf8_shorten($string, $length, $terminal); $this->assertEqual($expect, $result, 'Shortening of '.$string); } try { phutil_utf8_shorten('derp', 3, 'quack'); $caught = false; } catch (Exception $ex) { $caught = true; } $this->assertEqual(true, $caught, 'Expect exception for terminal.'); } public function testUTF8Wrap() { $inputs = array( array( 'aaaaaaa', 3, array( 'aaa', 'aaa', 'a', )), array( 'aaaaaaa', 3, array( 'aaa', 'aaa', 'a', )), array( 'aa&aaaa', 3, array( 'aa&', 'aaa', 'a', )), array( "aa\xe6\x9d\xb1aaaa", 3, array( "aa\xe6\x9d\xb1", 'aaa', 'a', )), array( '', 80, array( )), array( 'a', 80, array( 'a', )), ); foreach ($inputs as $input) { list($string, $width, $expect) = $input; $this->assertEqual( $expect, phutil_utf8_hard_wrap_html($string, $width), "Wrapping of '".$string."'"); } } public function testUTF8ConvertParams() { $caught = null; try { phutil_utf8_convert('', 'utf8', ''); } catch (Exception $ex) { $caught = $ex; } $this->assertEqual(true, (bool)$caught, 'Requires source encoding.'); $caught = null; try { phutil_utf8_convert('', '', 'utf8'); } catch (Exception $ex) { $caught = $ex; } $this->assertEqual(true, (bool)$caught, 'Requires target encoding.'); } public function testUTF8Convert() { if (!function_exists('mb_convert_encoding')) { $this->assertSkipped("Requires mbstring extension."); } // "[ae]gis se[n]or [(c)] 1970 [+/-] 1 [degree]" $input = "\xE6gis SE\xD1OR \xA9 1970 \xB11\xB0"; $expect = "\xC3\xA6gis SE\xC3\x91OR \xC2\xA9 1970 \xC2\xB11\xC2\xB0"; $output = phutil_utf8_convert($input, 'UTF-8', 'ISO-8859-1'); $this->assertEqual($expect, $output, 'Conversion from ISO-8859-1.'); $caught = null; try { phutil_utf8_convert('xyz', 'moon language', 'UTF-8'); } catch (Exception $ex) { $caught = $ex; } $this->assertEqual(true, (bool)$caught, 'Conversion with bogus encoding.'); } } diff --git a/src/utils/__tests__/PhutilUtilsTestCase.php b/src/utils/__tests__/PhutilUtilsTestCase.php index 3419e33..d1e249c 100644 --- a/src/utils/__tests__/PhutilUtilsTestCase.php +++ b/src/utils/__tests__/PhutilUtilsTestCase.php @@ -1,310 +1,310 @@ assertEqual( true, ($caught instanceof InvalidArgumentException)); } public function testMFilter_withEmptyValue_filtered() { $a = new MFilterTestHelper('o', 'p', 'q'); $b = new MFilterTestHelper('o', '', 'q'); $c = new MFilterTestHelper('o', 'p', 'q'); $list = array( 'a' => $a, 'b' => $b, 'c' => $c, ); $actual = mfilter($list, 'getI'); $expected = array( 'a' => $a, 'c' => $c, ); $this->assertEqual($expected, $actual); } public function testMFilter_withEmptyValueNegate_filtered() { $a = new MFilterTestHelper('o', 'p', 'q'); $b = new MFilterTestHelper('o', '', 'q'); $c = new MFilterTestHelper('o', 'p', 'q'); $list = array( 'a' => $a, 'b' => $b, 'c' => $c, ); $actual = mfilter($list, 'getI', true); $expected = array( 'b' => $b, ); $this->assertEqual($expected, $actual); } public function testIFilter_invalidIndex_throwException() { $caught = null; try { ifilter(array(), null); } catch (InvalidArgumentException $ex) { $caught = $ex; } $this->assertEqual( true, ($caught instanceof InvalidArgumentException)); } public function testIFilter_withEmptyValue_filtered() { $list = array( 'a' => array('h' => 'o', 'i' => 'p', 'j' => 'q',), 'b' => array('h' => 'o', 'i' => '', 'j' => 'q',), 'c' => array('h' => 'o', 'i' => 'p', 'j' => 'q',), 'd' => array('h' => 'o', 'i' => 0, 'j' => 'q',), 'e' => array('h' => 'o', 'i' => null, 'j' => 'q',), 'f' => array('h' => 'o', 'i' => false, 'j' => 'q',), ); $actual = ifilter($list, 'i'); $expected = array( 'a' => array('h' => 'o', 'i' => 'p', 'j' => 'q',), 'c' => array('h' => 'o', 'i' => 'p', 'j' => 'q',), ); $this->assertEqual($expected, $actual); } public function testIFilter_indexNotExists_allFiltered() { $list = array( 'a' => array('h' => 'o', 'i' => 'p', 'j' => 'q',), 'b' => array('h' => 'o', 'i' => '', 'j' => 'q',), ); $actual = ifilter($list, 'NoneExisting'); $expected = array(); $this->assertEqual($expected, $actual); } public function testIFilter_withEmptyValueNegate_filtered() { $list = array( 'a' => array('h' => 'o', 'i' => 'p', 'j' => 'q',), 'b' => array('h' => 'o', 'i' => '', 'j' => 'q',), 'c' => array('h' => 'o', 'i' => 'p', 'j' => 'q',), 'd' => array('h' => 'o', 'i' => 0, 'j' => 'q',), 'e' => array('h' => 'o', 'i' => null, 'j' => 'q',), 'f' => array('h' => 'o', 'i' => false, 'j' => 'q',), ); $actual = ifilter($list, 'i', true); $expected = array( 'b' => array('h' => 'o', 'i' => '', 'j' => 'q',), 'd' => array('h' => 'o', 'i' => 0, 'j' => 'q',), 'e' => array('h' => 'o', 'i' => null, 'j' => 'q',), 'f' => array('h' => 'o', 'i' => false, 'j' => 'q',), ); $this->assertEqual($expected, $actual); } public function testIFilter_indexNotExists_notFiltered() { $list = array( 'a' => array('h' => 'o', 'i' => 'p', 'j' => 'q',), 'b' => array('h' => 'o', 'i' => '', 'j' => 'q',), ); $actual = ifilter($list, 'NoneExisting', true); $expected = array( 'a' => array('h' => 'o', 'i' => 'p', 'j' => 'q',), 'b' => array('h' => 'o', 'i' => '', 'j' => 'q',), ); $this->assertEqual($expected, $actual); } public function testmergev_merging_basicallyWorksCorrectly() { $this->assertEqual( array(), array_mergev( array( // ))); $this->assertEqual( array(), array_mergev( array( array(), array(), array(), ))); $this->assertEqual( array(1, 2, 3, 4, 5), array_mergev( array( array(1, 2), array(3), array(), array(4, 5), ))); } public function testNonempty() { $this->assertEqual( 'zebra', nonempty(false, null, 0, '', array(), 'zebra')); $this->assertEqual( null, nonempty()); $this->assertEqual( false, nonempty(null, false)); $this->assertEqual( null, nonempty(false, null)); } public function testCoalesce() { $this->assertEqual( 'zebra', coalesce(null, 'zebra')); $this->assertEqual( null, coalesce()); $this->assertEqual( false, coalesce(false, null)); $this->assertEqual( false, coalesce(null, false)); } public function testHeadLast() { $this->assertEqual( 'a', head(explode('.', 'a.b'))); $this->assertEqual( 'b', last(explode('.', 'a.b'))); } public function testHeadKeyLastKey() { $this->assertEqual( 'a', head_key(array('a' => 0, 'b' => 1)) ); $this->assertEqual( 'b', last_key(array('a' => 0, 'b' => 1)) ); $this->assertEqual(NULL, head_key(array())); $this->assertEqual(NULL, last_key(array())); } public function testID() { $this->assertEqual(true, id(true)); $this->assertEqual(false, id(false)); } public function testIdx() { $array = array( 'present' => true, 'null' => null, ); $this->assertEqual(true, idx($array, 'present')); $this->assertEqual(true, idx($array, 'present', false)); $this->assertEqual(null, idx($array, 'null')); $this->assertEqual(null, idx($array, 'null', false)); $this->assertEqual(null, idx($array, 'missing')); $this->assertEqual(false, idx($array, 'missing', false)); } public function testSplitLines() { $retain_cases = array( "" => array(""), "x" => array("x"), "x\n" => array("x\n"), "\n" => array("\n"), "\n\n\n" => array("\n", "\n", "\n"), "\r\n" => array("\r\n"), "x\r\ny\n" => array("x\r\n", "y\n"), "x\ry\nz\r\n" => array("x\r", "y\n", "z\r\n"), "x\ry\nz\r\n\n" => array("x\r", "y\n", "z\r\n", "\n"), ); foreach ($retain_cases as $input => $expect) { $this->assertEqual( $expect, phutil_split_lines($input, $retain_endings = true), "(Retained) ".addcslashes($input, "\r\n\\")); } $discard_cases = array( "" => array(""), "x" => array("x"), "x\n" => array("x"), "\n" => array(""), "\n\n\n" => array("", "", ""), "\r\n" => array(""), "x\r\ny\n" => array("x", "y"), "x\ry\nz\r\n" => array("x", "y", "z"), "x\ry\nz\r\n\n" => array("x", "y", "z", ""), ); foreach ($discard_cases as $input => $expect) { $this->assertEqual( $expect, phutil_split_lines($input, $retain_endings = false), "(Discarded) ".addcslashes($input, "\r\n\\")); } } }