Skip to content

Commit bb63070

Browse files
authored
Merge pull request #126 from splumhoff/master
2 parents 7b09c52 + 0f428a7 commit bb63070

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

specs/~lambdas.json

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"php": "return \"world\";",
1616
"python": "lambda: \"world\"",
1717
"clojure": "(fn [] \"world\")",
18-
"lisp": "(lambda () \"world\")"
18+
"lisp": "(lambda () \"world\")",
19+
"pwsh": "\"world\""
1920
}
2021
},
2122
"template": "Hello, {{lambda}}!",
@@ -35,7 +36,8 @@
3536
"php": "return \"{{planet}}\";",
3637
"python": "lambda: \"{{planet}}\"",
3738
"clojure": "(fn [] \"{{planet}}\")",
38-
"lisp": "(lambda () \"{{planet}}\")"
39+
"lisp": "(lambda () \"{{planet}}\")",
40+
"pwsh": "\"{{planet}}\""
3941
}
4042
},
4143
"template": "Hello, {{lambda}}!",
@@ -55,7 +57,8 @@
5557
"php": "return \"|planet| => {{planet}}\";",
5658
"python": "lambda: \"|planet| => {{planet}}\"",
5759
"clojure": "(fn [] \"|planet| => {{planet}}\")",
58-
"lisp": "(lambda () \"|planet| => {{planet}}\")"
60+
"lisp": "(lambda () \"|planet| => {{planet}}\")",
61+
"pwsh": "\"|planet| => {{planet}}\""
5962
}
6063
},
6164
"template": "{{= | | =}}\nHello, (|&lambda|)!",
@@ -74,7 +77,8 @@
7477
"php": "global $calls; return ++$calls;",
7578
"python": "lambda: globals().update(calls=globals().get(\"calls\",0)+1) or calls",
7679
"clojure": "(def g (atom 0)) (fn [] (swap! g inc))",
77-
"lisp": "(let ((g 0)) (lambda () (incf g)))"
80+
"lisp": "(let ((g 0)) (lambda () (incf g)))",
81+
"pwsh": "if (($null -eq $script:calls) -or ($script:calls -ge 3)){$script:calls=0}; ++$script:calls; $script:calls"
7882
}
7983
},
8084
"template": "{{lambda}} == {{{lambda}}} == {{lambda}}",
@@ -93,7 +97,8 @@
9397
"php": "return \">\";",
9498
"python": "lambda: \">\"",
9599
"clojure": "(fn [] \">\")",
96-
"lisp": "(lambda () \">\")"
100+
"lisp": "(lambda () \">\")",
101+
"pwsh": "\">\""
97102
}
98103
},
99104
"template": "<{{lambda}}{{{lambda}}}",
@@ -113,7 +118,8 @@
113118
"php": "return ($text == \"{{x}}\") ? \"yes\" : \"no\";",
114119
"python": "lambda text: text == \"{{x}}\" and \"yes\" or \"no\"",
115120
"clojure": "(fn [text] (if (= text \"{{x}}\") \"yes\" \"no\"))",
116-
"lisp": "(lambda (text) (if (string= text \"{{x}}\") \"yes\" \"no\"))"
121+
"lisp": "(lambda (text) (if (string= text \"{{x}}\") \"yes\" \"no\"))",
122+
"pwsh": "if ($args[0] -eq \"{{x}}\") {\"yes\"} else {\"no\"}"
117123
}
118124
},
119125
"template": "<{{#lambda}}{{x}}{{/lambda}}>",
@@ -133,7 +139,8 @@
133139
"php": "return $text . \"{{planet}}\" . $text;",
134140
"python": "lambda text: \"%s{{planet}}%s\" % (text, text)",
135141
"clojure": "(fn [text] (str text \"{{planet}}\" text))",
136-
"lisp": "(lambda (text) (format nil \"~a{{planet}}~a\" text text))"
142+
"lisp": "(lambda (text) (format nil \"~a{{planet}}~a\" text text))",
143+
"pwsh": "\"$($args[0]){{planet}}$($args[0])\""
137144
}
138145
},
139146
"template": "<{{#lambda}}-{{/lambda}}>",
@@ -153,7 +160,8 @@
153160
"php": "return $text . \"{{planet}} => |planet|\" . $text;",
154161
"python": "lambda text: \"%s{{planet}} => |planet|%s\" % (text, text)",
155162
"clojure": "(fn [text] (str text \"{{planet}} => |planet|\" text))",
156-
"lisp": "(lambda (text) (format nil \"~a{{planet}} => |planet|~a\" text text))"
163+
"lisp": "(lambda (text) (format nil \"~a{{planet}} => |planet|~a\" text text))",
164+
"pwsh": "\"$($args[0]){{planet}} => |planet|$($args[0])\""
157165
}
158166
},
159167
"template": "{{= | | =}}<|#lambda|-|/lambda|>",
@@ -172,7 +180,8 @@
172180
"php": "return \"__\" . $text . \"__\";",
173181
"python": "lambda text: \"__%s__\" % (text)",
174182
"clojure": "(fn [text] (str \"__\" text \"__\"))",
175-
"lisp": "(lambda (text) (format nil \"__~a__\" text))"
183+
"lisp": "(lambda (text) (format nil \"__~a__\" text))",
184+
"pwsh": "\"__$($args[0])__\""
176185
}
177186
},
178187
"template": "{{#lambda}}FILE{{/lambda}} != {{#lambda}}LINE{{/lambda}}",
@@ -192,7 +201,8 @@
192201
"php": "return false;",
193202
"python": "lambda text: 0",
194203
"clojure": "(fn [text] false)",
195-
"lisp": "(lambda (text) (declare (ignore text)) nil)"
204+
"lisp": "(lambda (text) (declare (ignore text)) nil)",
205+
"pwsh": "$false"
196206
}
197207
},
198208
"template": "<{{^lambda}}{{static}}{{/lambda}}>",

specs/~lambdas.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ tests:
2424
python: 'lambda: "world"'
2525
clojure: '(fn [] "world")'
2626
lisp: '(lambda () "world")'
27+
pwsh: '"world"'
2728
template: "Hello, {{lambda}}!"
2829
expected: "Hello, world!"
2930

@@ -40,6 +41,7 @@ tests:
4041
python: 'lambda: "{{planet}}"'
4142
clojure: '(fn [] "{{planet}}")'
4243
lisp: '(lambda () "{{planet}}")'
44+
pwsh: '"{{planet}}"'
4345
template: "Hello, {{lambda}}!"
4446
expected: "Hello, world!"
4547

@@ -56,6 +58,7 @@ tests:
5658
python: 'lambda: "|planet| => {{planet}}"'
5759
clojure: '(fn [] "|planet| => {{planet}}")'
5860
lisp: '(lambda () "|planet| => {{planet}}")'
61+
pwsh: '"|planet| => {{planet}}"'
5962
template: "{{= | | =}}\nHello, (|&lambda|)!"
6063
expected: "Hello, (|planet| => world)!"
6164

@@ -71,6 +74,7 @@ tests:
7174
python: 'lambda: globals().update(calls=globals().get("calls",0)+1) or calls'
7275
clojure: '(def g (atom 0)) (fn [] (swap! g inc))'
7376
lisp: '(let ((g 0)) (lambda () (incf g)))'
77+
pwsh: 'if (($null -eq $script:calls) -or ($script:calls -ge 3)){$script:calls=0}; ++$script:calls; $script:calls'
7478
template: '{{lambda}} == {{{lambda}}} == {{lambda}}'
7579
expected: '1 == 2 == 3'
7680

@@ -86,6 +90,7 @@ tests:
8690
python: 'lambda: ">"'
8791
clojure: '(fn [] ">")'
8892
lisp: '(lambda () ">")'
93+
pwsh: '">"'
8994
template: "<{{lambda}}{{{lambda}}}"
9095
expected: "<&gt;>"
9196

@@ -102,6 +107,7 @@ tests:
102107
python: 'lambda text: text == "{{x}}" and "yes" or "no"'
103108
clojure: '(fn [text] (if (= text "{{x}}") "yes" "no"))'
104109
lisp: '(lambda (text) (if (string= text "{{x}}") "yes" "no"))'
110+
pwsh: 'if ($args[0] -eq "{{x}}") {"yes"} else {"no"}'
105111
template: "<{{#lambda}}{{x}}{{/lambda}}>"
106112
expected: "<yes>"
107113

@@ -118,6 +124,7 @@ tests:
118124
python: 'lambda text: "%s{{planet}}%s" % (text, text)'
119125
clojure: '(fn [text] (str text "{{planet}}" text))'
120126
lisp: '(lambda (text) (format nil "~a{{planet}}~a" text text))'
127+
pwsh: '"$($args[0]){{planet}}$($args[0])"'
121128
template: "<{{#lambda}}-{{/lambda}}>"
122129
expected: "<-Earth->"
123130

@@ -134,6 +141,7 @@ tests:
134141
python: 'lambda text: "%s{{planet}} => |planet|%s" % (text, text)'
135142
clojure: '(fn [text] (str text "{{planet}} => |planet|" text))'
136143
lisp: '(lambda (text) (format nil "~a{{planet}} => |planet|~a" text text))'
144+
pwsh: '"$($args[0]){{planet}} => |planet|$($args[0])"'
137145
template: "{{= | | =}}<|#lambda|-|/lambda|>"
138146
expected: "<-{{planet}} => Earth->"
139147

@@ -149,6 +157,7 @@ tests:
149157
python: 'lambda text: "__%s__" % (text)'
150158
clojure: '(fn [text] (str "__" text "__"))'
151159
lisp: '(lambda (text) (format nil "__~a__" text))'
160+
pwsh: '"__$($args[0])__"'
152161
template: '{{#lambda}}FILE{{/lambda}} != {{#lambda}}LINE{{/lambda}}'
153162
expected: '__FILE__ != __LINE__'
154163

@@ -165,5 +174,6 @@ tests:
165174
python: 'lambda text: 0'
166175
clojure: '(fn [text] false)'
167176
lisp: '(lambda (text) (declare (ignore text)) nil)'
177+
pwsh: '$false'
168178
template: "<{{^lambda}}{{static}}{{/lambda}}>"
169179
expected: "<>"

0 commit comments

Comments
 (0)