Extension:Expect/zh

This page is a translated version of the page Extension:Expect and the translation is 0% complete.
MediaWiki扩展手冊
OOjs UI icon advanced.svg
Expect
发布状态: 测试版
Keepcalms.png
实现 API
描述 Provides extended assertions for Scribunto.
作者
  • John Erling Blad (Jeblad讨论)
最新版本 0.1.0
兼容性方针 master分支向后兼容。
MediaWiki >= 1.33
数据庫更改
Composer jeblad/expect
许可协议 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' );
    
  • Yes 完成 – 在您的wiki上导航至Special:Version,以验证已成功安装扩展。

Usage

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.

Development

For recreating the Vagrant-based development environment, see Expect: Topics/Vagrant.

See also