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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
/*
Copyright 2015 Google Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Golden
local bash_golden = std.lines([
"#!/bin/bash",
"if [ $# -lt 1 ] ; then",
" echo \"No arguments!\"",
"else",
" echo \"$# arguments!\"",
"fi",
]);
// Soft tabs
local bash_soft = |||
#!/bin/bash
if [ $# -lt 1 ] ; then
echo "No arguments!"
else
echo "$# arguments!"
fi
|||;
std.assertEqual(bash_golden, bash_soft) &&
// Hard tabs
local bash_hard = |||
#!/bin/bash
if [ $# -lt 1 ] ; then
echo "No arguments!"
else
echo "$# arguments!"
fi
|||;
std.assertEqual(bash_golden, bash_hard) &&
// Mixed tabs
local bash_mixed = |||
#!/bin/bash
if [ $# -lt 1 ] ; then
echo "No arguments!"
else
echo "$# arguments!"
fi
|||;
std.assertEqual(bash_golden, bash_mixed) &&
// More indent
local str1 = |||
text
|||;
std.assertEqual(str1, "text\n") &&
// Escape chars
local str1 = |||
\n
|||;
std.assertEqual(str1, "\\n\n") &&
// Blank line with trailing whitespace
local blank_line1 = |||
foo
bar
|||;
std.assertEqual(blank_line1, "foo\n\nbar\n") &&
// Blank line no trailing whitespace
local blank_line2 = |||
foo
bar
|||;
std.assertEqual(blank_line2, "foo\n\nbar\n") &&
// Initial blank line
local blank_line3 = |||
foo
|||;
std.assertEqual(blank_line3, "\nfoo\n") &&
// Interaction with operators (1)
local op1 = "foo"+|||
foo
|||;
std.assertEqual(op1, "foofoo\n") &&
// Interaction with operators (2)
local op2 = "foo"<|||
foo
|||;
std.assertEqual(op2, true) &&
// whitespace after |||
local whitespace_after = |||
foo
|||;
std.assertEqual(whitespace_after, "foo\n") &&
true
|