Extension:Expect

This page is a translated version of the page Extension:Expect and the translation is 100% complete.
MediaWiki extensions manual
Expect
Release status: beta
Implementation API
Description Tilbyr utvida assertions i Scribunto.
Author(s)
  • John Erling Blad (Jebladdiskusjon)
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
README, LDoc
Translate the Expect extension

Expect tilbyr eit utvida rammeverk for assertions.

Det er basert på beregningsgrafer som er ferdiglagd før de vert brukt for omfattande kontrollar.

Installering

Expect er avhengig av modular frå Scribunto -utvidinga.

  • Download and place the file(s) in a directory called Expect in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'Expect' );
    
  •   Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Bruk

Arbeidsflyten er å definera ein graf, og deretter gje argument til grafen. Definisjonen er gjord ein gong, men grafen kan brukast på nytt fleire gonger.

-- 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 meir hjelp, sjå den genererte LDoc dokumentasjonen.

Utvikling

For å attskape det Vagrant-baserte utviklingsmiljøet, sjå Expect: Topics/Vagrant.

Sjå òg