Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

// request.cf · coarse context

A page that knows where it met you.

Only coarse request metadata is shown. This demo does not display or persist visitor IP addresses.

Country
US
Cloudflare location
CMH
Connection
HTTP/2
Language
Not provided

Ray ID: a21db4dd9bf04628

Jump to content

Module:Ustring/testcases

From Wikipedia, the free encyclopedia
-- Unit tests for [[Module:Ustring]]. Click talk page to run tests.
local p = require('Module:UnitTests')

-- Test sub function
function p:test_sub()
	self:preprocess_equals_sandbox_many('{{#invoke:ustring', 'sub', {
		{' hello | 1 | 3', ' he'},
		{' s1 = hello | 1 | 3', 'hel'},
		{' s1 = hello | 0 | 3', 'hel'},
		{' s1 = hello | -3 ', 'llo'},
		{' hello | -3 ', 'lo '},
	})
end

-- Test error supression
function p:test_onerror()
	self:preprocess_equals_sandbox_many('{{#invoke:ustring', 'sub', {
		{' hello | 1 | 3 | onerror = foo', ' he'},
		{' s1 = hello | bar | 3 | onerror = foo', 'foo'},
		{' s1 = hello | 0 |  | onerror = foo', 'foo'},
	})
end

-- Test find/replace
function p:test_gsub()
	self:preprocess_equals_sandbox_many('{{#invoke:ustring', 'gsub', {
		{' hello world | world | x ', ' hello x '},
		{' hello world| world | x ', ' hello world'},
	})
end

return p