Extension:Expect/de-formal
![]() Release status: beta |
|
---|---|
![]() |
|
Implementation | API |
Description | Provides extended assertions for Scribunto. |
Author(s) |
|
Latest version | 0.1.0 |
Compatibility policy | Master maintains backward compatibility. |
MediaWiki | >= 1.33 |
Database changes | No |
Composer | jeblad/expect |
License | GNU General Public License 2.0 or later |
Download | GitHub: Note: README, LDoc |
Translate the Expect extension | |
Expect provides an extended framework for assertions.
It is based upon compute graphs that are predefined before being used for extensive checks.
Installation
Expect depends on modules from the Scribunto extension.
- Die Erweiterung herunterladen und die Datei(en) in ein Verzeichnis namens
Expect
im Ordnerextensions/
ablegen. - Folgenden Code am Ende Ihrer LocalSettings.php -Datei hinzufügen:
wfLoadExtension( 'Expect' );
Done – Zu Special:Version in dem Wiki (bei Einstellung auf deutsch nach Spezial:Version) navigieren, um die erfolgreiche Installierung der Erweiterung zu überprüfen.
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.