-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement SPICE-0009 External Readers
[SPICE-0009](apple/pkl-evolution#10) New close flow
- Loading branch information
Showing
52 changed files
with
1,647 additions
and
352 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/** | ||
* Copyright © 2024 Apple Inc. and the Pkl project authors. 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 | ||
* | ||
* https://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. | ||
*/ | ||
package org.pkl.commons | ||
|
||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.jupiter.api.Test | ||
|
||
class ShlexTest { | ||
|
||
@Test | ||
fun `empty input produces empty output`() { | ||
assertThat(shlex("")).isEqualTo(emptyList<String>()) | ||
} | ||
|
||
@Test | ||
fun `whitespace input produces empty output`() { | ||
assertThat(shlex(" \n \t ")).isEqualTo(emptyList<String>()) | ||
} | ||
|
||
@Test | ||
fun `regular token parsing`() { | ||
assertThat(shlex("\nabc def\tghi ")).isEqualTo(listOf("abc", "def", "ghi")) | ||
} | ||
|
||
@Test | ||
fun `single quoted token parsing`() { | ||
assertThat(shlex("'this is a single token'")).isEqualTo(listOf("this is a single token")) | ||
} | ||
|
||
@Test | ||
fun `double quoted token parsing`() { | ||
assertThat(shlex("\"this is a single token\"")).isEqualTo(listOf("this is a single token")) | ||
} | ||
|
||
@Test | ||
fun `escaping handles double quotes`() { | ||
assertThat(shlex(""""\"this is a single double quoted token\""""")) | ||
.isEqualTo(listOf("\"this is a single double quoted token\"")) | ||
} | ||
|
||
@Test | ||
fun `escaping does not apply within single quotes`() { | ||
assertThat(shlex("""'this is a single \" token'""")) | ||
.isEqualTo(listOf("""this is a single \" token""")) | ||
} | ||
|
||
@Test | ||
fun `adjacent quoted strings are one token`() { | ||
assertThat(shlex(""""single"' joined 'token""")).isEqualTo(listOf("single joined token")) | ||
assertThat(shlex(""""single"' 'token""")).isEqualTo(listOf("single token")) | ||
} | ||
|
||
@Test | ||
fun `space escapes do not split tokens`() { | ||
assertThat(shlex("""single\ token""")).isEqualTo(listOf("single token")) | ||
} | ||
|
||
@Test | ||
fun `empty quotes produce a single empty token`() { | ||
assertThat(shlex("\"\"")).isEqualTo(listOf("")) | ||
assertThat(shlex("''")).isEqualTo(listOf("")) | ||
assertThat(shlex("'' ''")).isEqualTo(listOf("", "")) | ||
assertThat(shlex("''''")).isEqualTo(listOf("")) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.