Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 50d0b893bb
Fetching contributors…

Cannot retrieve contributors at this time

executable file 101 lines (76 sloc) 1.938 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
#! /usr/bin/lua
--
-- lua-TestMore : <http://fperrad.github.com/lua-TestMore/>
--
-- Copyright (C) 2010, Perrad Francois
--
-- This code is licensed under the terms of the MIT/X11 license,
-- like Lua itself.
--

--[[

=head1 Lua Lexicography

=head2 Synopsis

% prove 203-lexico.t

=head2 Description

See "Lua 5.2 Reference Manual", section 3.1 "Lexical Conventions",
L<http://www.lua.org/manual/5.2/manual.html#3.1>.

=cut

--]]

require 'Test.More'

plan(29)

is("\65", "A")
is("\065", "A")

is(string.byte("\a"), 7)
is(string.byte("\b"), 8)
is(string.byte("\f"), 12)
is(string.byte("\n"), 10)
is(string.byte("\r"), 13)
is(string.byte("\t"), 9)
is(string.byte("\v"), 11)
is(string.byte("\\"), 92)

is(string.len("A\0B"), 3)

f, msg = loadstring [[a = "A\300"]]
like(msg, "^[^:]+:%d+: .- near")

f, msg = loadstring [[a = " unfinished string ]]
like(msg, "^[^:]+:%d+: unfinished string near")

f, msg = loadstring [[a = " unfinished string
]]
like(msg, "^[^:]+:%d+: unfinished string near")

f, msg = loadstring [[a = " unfinished string \
]]
like(msg, "^[^:]+:%d+: unfinished string near")

f, msg = loadstring [[a = " unfinished string \]]
like(msg, "^[^:]+:%d+: unfinished string near")

f, msg = loadstring "a = [[ unfinished long string "
like(msg, "^[^:]+:%d+: unfinished long string near")

f, msg = loadstring "a = [== invalid long string delimiter "
like(msg, "^[^:]+:%d+: invalid long string delimiter near")

a = 'alo\n123"'
is('alo\n123"', a)
is("alo\n123\"", a)
is('\97lo\10\04923"', a)
is([[alo
123"]], a)
is([==[
alo
123"]==], a)

is(3.0, 3)
is(314.16e-2, 3.1416)
is(0.31416E1, 3.1416)
is(0xff, 255)
is(0x56, 86)

--[===[
--[[
--[=[
nested long comments
--]=]
--]]
--]===]

f, msg = loadstring " --[[ unfinished long comment "
like(msg, "^[^:]+:%d+: unfinished long comment near")

-- Local Variables:
-- mode: lua
-- lua-indent-level: 4
-- fill-column: 100
-- End:
-- vim: ft=lua expandtab shiftwidth=4:
Something went wrong with that request. Please try again.