|
| 1 | +# TestSwiftRegex.py |
| 2 | +# |
| 3 | +# This source file is part of the Swift.org open source project |
| 4 | +# |
| 5 | +# Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors |
| 6 | +# Licensed under Apache License v2.0 with Runtime Library Exception |
| 7 | +# |
| 8 | +# See https://swift.org/LICENSE.txt for license information |
| 9 | +# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
| 10 | +# |
| 11 | +# ------------------------------------------------------------------------------ |
| 12 | +""" |
| 13 | +Test Swift's regex support |
| 14 | +""" |
| 15 | +import lldb |
| 16 | +from lldbsuite.test.lldbtest import * |
| 17 | +from lldbsuite.test.decorators import * |
| 18 | +import lldbsuite.test.lldbutil as lldbutil |
| 19 | + |
| 20 | + |
| 21 | +class TestSwiftRegex(TestBase): |
| 22 | + mydir = TestBase.compute_mydir(__file__) |
| 23 | + |
| 24 | + def setUp(self): |
| 25 | + TestBase.setUp(self) |
| 26 | + self.main_source = "main.swift" |
| 27 | + self.main_source_spec = lldb.SBFileSpec(self.main_source) |
| 28 | + |
| 29 | + @swiftTest |
| 30 | + def test_swift_regex(self): |
| 31 | + """Test Swift's regex support""" |
| 32 | + self.build() |
| 33 | + lldbutil.run_to_source_breakpoint( |
| 34 | + self, 'Set breakpoint here', self.main_source_spec) |
| 35 | + self.expect('v regex', |
| 36 | + substrs=['_StringProcessing.Regex<(Substring, Substring, Substring, Substring)>) regex = {']) |
| 37 | + self.expect('po regex', |
| 38 | + substrs=['Regex<(Substring, Substring, Substring, Substring)>']) |
| 39 | + |
| 40 | + self.expect('v dslRegex', |
| 41 | + substrs=['(_StringProcessing.Regex<Substring>) dslRegex = {']) |
| 42 | + self.expect('po dslRegex', |
| 43 | + substrs=['Regex<Substring>']) |
| 44 | + |
| 45 | + @swiftTest |
| 46 | + # Expected to fail because of availability checking while Regex support isn't stabilized |
| 47 | + @expectedFailureDarwin |
| 48 | + def test_swift_regex_in_exp(self): |
| 49 | + """Test Swift's regex support""" |
| 50 | + self.build() |
| 51 | + lldbutil.run_to_source_breakpoint( |
| 52 | + self, 'Set breakpoint here', self.main_source_spec) |
| 53 | + self.runCmd( |
| 54 | + "settings set target.experimental.swift-enable-bare-slash-regex true") |
| 55 | + self.expect('e -- /Order from <(.*)>, type: (.*), count in dozen: ([0-9]+)/', |
| 56 | + substrs=['_StringProcessing.Regex<(Substring, Substring, Substring, Substring)>']) |
0 commit comments