
KeysTest.pudu
Pudu29 lines1.4 KB
1/** @Test.Domain.Keys.Suite — field names to variable names */2module PuduLangEnvironment.Domain.KeysTest34import Std.Io as Io5import Std.Test as Test6import PuduLangEnvironment.Domain.Keys as Keys789fn main() -> Int {10 let checks = Test.suite("Domain.Keys", &[11 Test.equals("a lower-case name is upper-cased", &Keys.fromField("port"), &"PORT"),12 Test.equals("each word is separated", &Keys.fromField("databaseUrl"), &"DATABASE_URL"),13 Test.equals("a digit before a capital separates", &Keys.fromField("redis2Host"), &"REDIS2_HOST"),14 Test.equals("a run of capitals stays together", &Keys.fromField("apiURL"), &"API_URL"),15 Test.equals("a leading capital is not separated", &Keys.fromField("Port"), &"PORT"),16 Test.equals("an upper snake name is kept", &Keys.fromField("API_KEY"), &"API_KEY"),17 Test.equals("an underscore is kept", &Keys.fromField("max_retries"), &"MAX_RETRIES"),18 Test.equals("a dotted setting spells its variable with underscores", &Keys.fromSetting("server.port"), &"SERVER_PORT"),19 Test.equals("a dashed setting spells its variable with underscores", &Keys.fromSetting("log-level.file"), &"LOG_LEVEL_FILE"),20 Test.equals("a setting's letters are upper-cased as they are", &Keys.fromSetting("dbUrl"), &"DBURL"),21 Test.equals("an empty name stays empty", &Keys.fromField(""), &"")22 ])23 let ran = Test.run(&checks)24 for failure in Test.failuresOf(&ran) {25 let _reported = Io.writeErrorLine(failure)26 }27 Test.report(&ran)28}29