/opt/local/var/macports/build/augeas-9bb98f7d/work/augeas-1.12.0/lenses/tests/test_toml.aug - Augeas Documentation

# test_toml.aug

Summary

test_toml.aug |
Augeas Tests |
Toml.norec | String value
Toml.norec | Integer value
Toml.norec | Positive integer value
Toml.norec | Negative integer value
Toml.norec | Large integer value
Toml.norec | Hexadecimal integer value
Toml.norec | Octal integer value
Toml.norec | Binary integer value
Toml.norec | Float value
Toml.norec | Positive float value
Toml.norec | Negative float value
Toml.norec | Complex float value
Toml.norec | Inf float value
Toml.norec | Nan float value
Toml.norec | Bool value
Toml.norec | Datetime value
Toml.norec | Date value
Toml.norec | Time value
Toml.norec | String value with newline
Toml.norec | Multiline value
Toml.norec | Literal string value
Toml.array_norec | Empty array
Toml.array_norec | Array of strings
Toml.array_norec | Array of arrays
Toml.lns | Global parameters
Toml.lns | Simple section/value
Toml.lns | Subsections
Toml.lns | Nested subsections
Toml.lns | Arrays of tables
Toml.entry | Empty inline table
Toml.entry | Inline table
Augeas Variables |
example | The example from https://github.com/mojombo/toml

### Augeas Tests

### Toml.norec

> test Toml.norec get "\"foo\"" = { "string" = "foo" }

String value

### Toml.norec

> test Toml.norec get "42" = { "integer" = "42" }

Integer value

### Toml.norec

> test Toml.norec get "+42" = { "integer" = "+42" }

Positive integer value

### Toml.norec

> test Toml.norec get "-42" = { "integer" = "-42" }

Negative integer value

### Toml.norec

> test Toml.norec get "5_349_221" = { "integer" = "5_349_221" }

Large integer value

### Toml.norec

> test Toml.norec get "0xDEADBEEF" = { "integer" = "0xDEADBEEF" }

Hexadecimal integer value

### Toml.norec

> test Toml.norec get "0o755" = { "integer" = "0o755" }

Octal integer value

### Toml.norec

> test Toml.norec get "0b11010110" = { "integer" = "0b11010110" }

Binary integer value

### Toml.norec

> test Toml.norec get "3.14" = { "float" = "3.14" }

Float value

### Toml.norec

> test Toml.norec get "+3.14" = { "float" = "+3.14" }

Positive float value

### Toml.norec

> test Toml.norec get "-3.14" = { "float" = "-3.14" }

Negative float value

### Toml.norec

> test Toml.norec get "-3_220.145_223e-34" = { "float" = "-3_220.145_223e-34" }

Complex float value

### Toml.norec

> test Toml.norec get "-inf" = { "float" = "-inf" }

Inf float value

### Toml.norec

> test Toml.norec get "-nan" = { "float" = "-nan" }

Nan float value

### Toml.norec

> test Toml.norec get "true" = { "bool" = "true" }

Bool value

### Toml.norec

> test Toml.norec get "1979-05-27T07:32:00Z" = { "datetime" = "1979-05-27T07:32:00Z" }

Datetime value

### Toml.norec

> test Toml.norec get "1979-05-27" = { "date" = "1979-05-27" }

Date value

### Toml.norec

> test Toml.norec get "07:32:00" = { "time" = "07:32:00" }

Time value

### Toml.norec

> test Toml.norec get "\"bar\nbaz\"" = { "string" = "bar\nbaz" }

String value with newline

### Toml.norec

> test Toml.norec get "\"\"\"\nbar\nbaz\n \"\"\"" = { "string_multi" = "bar\nbaz" }

Multiline value

### Toml.norec

> test Toml.norec get "'bar\nbaz'" = { "string_literal" = "bar\nbaz" }

Literal string value

### Toml.array_norec

> test Toml.array_norec get "[ ]" = { "array" {} }

Empty array

### Toml.array_norec

> test Toml.array_norec get "[ \"foo\", \"bar\" ]" = { "array" {} { "string" = "foo" } {} { "string" = "bar" } {} }

Array of strings

### Toml.array_norec

Array of arrays

### Toml.lns

> test Toml.lns get "# Globals foo = \"bar\"\n" = { "#comment" = "Globals" } { "entry" = "foo" { "string" = "bar" } }

Global parameters

### Toml.lns

> test Toml.lns get "[foo] bar = \"baz\"\n" = { "table" = "foo" { "entry" = "bar" { "string" = "baz" } } }

Simple section/value

### Toml.lns

> test Toml.lns get "[foo] title = \"bar\" [foo.one] hello = \"world\"\n" = { "table" = "foo" { "entry" = "title" { "string" = "bar" } } } { "table" = "foo.one" { "entry" = "hello" { "string" = "world" } } }

Subsections

### Toml.lns

> test Toml.lns get "[foo] [foo.one] [foo.one.two] bar = \"baz\"\n" = { "table" = "foo" } { "table" = "foo.one" } { "table" = "foo.one.two" { "entry" = "bar" { "string" = "baz" } } }

Nested subsections

### Toml.lns

> test Toml.lns get "[[products]] name = \"Hammer\" sku = 738594937 [[products]] [[products]] name = \"Nail\" sku = 284758393 color = \"gray\"\n" = { "@table" = "products" { "entry" = "name" { "string" = "Hammer" } } { "entry" = "sku" { "integer" = "738594937" } } { } } { "@table" = "products" { } } { "@table" = "products" { "entry" = "name" { "string" = "Nail" } } { "entry" = "sku" { "integer" = "284758393" } } { "entry" = "color" { "string" = "gray" } } }

Arrays of tables

### Toml.entry

> test Toml.entry get "name = { }\n" = { "entry" = "name" { "inline_table" { } } }

Empty inline table

### Toml.entry

> test Toml.entry get "name = { first = \"Tom\", last = \"Preston-Werner\" }\n" = { "entry" = "name" { "inline_table" {} { "entry" = "first" { "string" = "Tom" } } {} { "entry" = "last" { "string" = "Preston-Werner" } } {} } }

Inline table

### Augeas Variables

### example

> let example = "# This is a TOML document. Boom. title = \"TOML Example\" [owner] name = \"Tom Preston-Werner\" organization = \"GitHub\" bio = \"GitHub Cofounder & CEO\nLikes tater tots and beer.\" dob = 1979-05-27T07:32:00Z # First class dates? Why not? [database] server = \"192.168.1.1\" ports = [ 8001, 8001, 8002 ] connection_max = 5000 enabled = true [servers] # You can indent as you please. Tabs or spaces. TOML don't care. [servers.alpha] ip = \"10.0.0.1\" dc = \"eqdc10\" [servers.beta] ip = \"10.0.0.2\" dc = \"eqdc10\" country = \"中国\" # This should be parsed as UTF-8 [clients] data = [ [\"gamma\", \"delta\"], [1, 2] ] # just an update to make sure parsers support it # Line breaks are OK when inside arrays hosts = [ \"alpha\", \"omega\" ] # Products [[products]] name = \"Hammer\" sku = 738594937 [[products]] name = \"Nail\" sku = 284758393 color = \"gray\" " test Toml.lns get example = { "#comment" = "This is a TOML document. Boom." } { } { "entry" = "title" { "string" = "TOML Example" } } { } { "table" = "owner" { "entry" = "name" { "string" = "Tom Preston-Werner" } } { "entry" = "organization" { "string" = "GitHub" } } { "entry" = "bio" { "string" = "GitHub Cofounder & CEO Likes tater tots and beer." } } { "entry" = "dob" { "datetime" = "1979-05-27T07:32:00Z" } { "#comment" = "First class dates? Why not?" } } { } } { "table" = "database" { "entry" = "server" { "string" = "192.168.1.1" } } { "entry" = "ports" { "array" { } { "integer" = "8001" } { } { "integer" = "8001" } { } { "integer" = "8002" } { } } } { "entry" = "connection_max" { "integer" = "5000" } } { "entry" = "enabled" { "bool" = "true" } } { } } { "table" = "servers" { } { "#comment" = "You can indent as you please. Tabs or spaces. TOML don't care." } } { "table" = "servers.alpha" { "entry" = "ip" { "string" = "10.0.0.1" } } { "entry" = "dc" { "string" = "eqdc10" } } { } } { "table" = "servers.beta" { "entry" = "ip" { "string" = "10.0.0.2" } } { "entry" = "dc" { "string" = "eqdc10" } } { "entry" = "country" { "string" = "中国" } { "#comment" = "This should be parsed as UTF-8" } } { } } { "table" = "clients" { "entry" = "data" { "array" { } { "array" { "string" = "gamma" } { } { "string" = "delta" } } { } { "array" { "integer" = "1" } { } { "integer" = "2" } } { } } { "#comment" = "just an update to make sure parsers support it" } } { } { "#comment" = "Line breaks are OK when inside arrays" } { "entry" = "hosts" { "array" { } { "string" = "alpha" } { } { "string" = "omega" } { } } } { } { "#comment" = "Products" } { } } { "@table" = "products" { "entry" = "name" { "string" = "Hammer" } } { "entry" = "sku" { "integer" = "738594937" } } { } } { "@table" = "products" { "entry" = "name" { "string" = "Nail" } } { "entry" = "sku" { "integer" = "284758393" } } { "entry" = "color" { "string" = "gray" } } }

The example from https://github.com/mojombo/toml

> test Toml.norec get "\"foo\"" = { "string" = "foo" }

String value

> test Toml.array_norec get "[ ]" = { "array" {} }

Empty array

> test Toml.lns get "# Globals foo = \"bar\"\n" = { "#comment" = "Globals" } { "entry" = "foo" { "string" = "bar" } }

Global parameters

> test Toml.entry get "name = { }\n" = { "entry" = "name" { "inline_table" { } } }

Empty inline table

> let example = "# This is a TOML document. Boom. title = \"TOML Example\" [owner] name = \"Tom Preston-Werner\" organization = \"GitHub\" bio = \"GitHub Cofounder & CEO\nLikes tater tots and beer.\" dob = 1979-05-27T07:32:00Z # First class dates? Why not? [database] server = \"192.168.1.1\" ports = [ 8001, 8001, 8002 ] connection_max = 5000 enabled = true [servers] # You can indent as you please. Tabs or spaces. TOML don't care. [servers.alpha] ip = \"10.0.0.1\" dc = \"eqdc10\" [servers.beta] ip = \"10.0.0.2\" dc = \"eqdc10\" country = \"中国\" # This should be parsed as UTF-8 [clients] data = [ [\"gamma\", \"delta\"], [1, 2] ] # just an update to make sure parsers support it # Line breaks are OK when inside arrays hosts = [ \"alpha\", \"omega\" ] # Products [[products]] name = \"Hammer\" sku = 738594937 [[products]] name = \"Nail\" sku = 284758393 color = \"gray\" " test Toml.lns get example = { "#comment" = "This is a TOML document. Boom." } { } { "entry" = "title" { "string" = "TOML Example" } } { } { "table" = "owner" { "entry" = "name" { "string" = "Tom Preston-Werner" } } { "entry" = "organization" { "string" = "GitHub" } } { "entry" = "bio" { "string" = "GitHub Cofounder & CEO Likes tater tots and beer." } } { "entry" = "dob" { "datetime" = "1979-05-27T07:32:00Z" } { "#comment" = "First class dates? Why not?" } } { } } { "table" = "database" { "entry" = "server" { "string" = "192.168.1.1" } } { "entry" = "ports" { "array" { } { "integer" = "8001" } { } { "integer" = "8001" } { } { "integer" = "8002" } { } } } { "entry" = "connection_max" { "integer" = "5000" } } { "entry" = "enabled" { "bool" = "true" } } { } } { "table" = "servers" { } { "#comment" = "You can indent as you please. Tabs or spaces. TOML don't care." } } { "table" = "servers.alpha" { "entry" = "ip" { "string" = "10.0.0.1" } } { "entry" = "dc" { "string" = "eqdc10" } } { } } { "table" = "servers.beta" { "entry" = "ip" { "string" = "10.0.0.2" } } { "entry" = "dc" { "string" = "eqdc10" } } { "entry" = "country" { "string" = "中国" } { "#comment" = "This should be parsed as UTF-8" } } { } } { "table" = "clients" { "entry" = "data" { "array" { } { "array" { "string" = "gamma" } { } { "string" = "delta" } } { } { "array" { "integer" = "1" } { } { "integer" = "2" } } { } } { "#comment" = "just an update to make sure parsers support it" } } { } { "#comment" = "Line breaks are OK when inside arrays" } { "entry" = "hosts" { "array" { } { "string" = "alpha" } { } { "string" = "omega" } { } } } { } { "#comment" = "Products" } { } } { "@table" = "products" { "entry" = "name" { "string" = "Hammer" } } { "entry" = "sku" { "integer" = "738594937" } } { } } { "@table" = "products" { "entry" = "name" { "string" = "Nail" } } { "entry" = "sku" { "integer" = "284758393" } } { "entry" = "color" { "string" = "gray" } } }

The example from https://github.com/mojombo/toml
Close