Extension:Expect
Jump to navigation
Jump to search
Expect リリースの状態: ベータ |
|
---|---|
![]() |
|
実装 | API |
説明 | Provides extended assertions for Scribunto. |
作者 | |
互換性ポリシー | Master maintains backwards compatibility. |
データベースの変更 | いいえ |
ライセンス | GNU 一般公衆利用許諾書 2.0 以降 |
ダウンロード | README, LDoc |
Expect 拡張機能の翻訳にご協力ください | |
Expect provides an extended framework for assertions.
It is based upon compute graphs that are predefined before being used for extensive checks.
インストール
Expect depends on modules from the Scribunto extension.
- ダウンロードして、ファイルを
extensions/
フォルダー内のExpect
という名前のディレクトリ内に配置します。 - 以下のコードを LocalSettings.php の末尾に追加します:
wfLoadExtension( 'Expect' );
完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。
使用法
The workflow is to define a graph, and then provide arguments to that graph. The definition is done once, but the graph can be reused several times.
-- Load the lib
local expect = require 'expect'
-- Create a few compute graphs
local expectString = expect:create():asType():toBeEqual( 'string' )
local expectNoColon = expect:create():toBeUMatch( '^[^:]*$' )
-- Create an exported hash
local p = {}
-- Add a function
function p.helloWorld( name )
-- Call the compute graphs
expectString( name )
expectNoColon( name )
-- Should be safe to do whatever now
return mw.ustring.format( 'Hi there %s!', name )
end
-- Return the exported hash
return p
For further help, see the generated LDoc documentation.
開発
For recreating the Vagrant-based development environment, see Expect: Topics/Vagrant.