【问题标题】:Use foreach or regex to verify in Eclipse RCPTT在 Eclipse RCPTT 中使用 foreach 或 regex 进行验证
【发布时间】:2018-10-19 21:18:10
【问题描述】:

在 RCPTT 录制后,我有以下脚本:

get-editor "test.c" | get-text-viewer | get-property "markers['31'][0].Type" 
| equals "text-to-verify" | verify-true

markers['31'][0].Type 的值介于 markers['0'][0].Type - markers['45'][0].Type 之间,并且数字是动态的。

我想检查任何标记类型是否包含特定值。

但我不能使用.*foreach

我该如何解决这个问题?

【问题讨论】:

    标签: eclipse eclipse-rcptt


    【解决方案1】:
    // This will store the comma separated list
    global [val indices 0]
    // Set to expected size of indices (10)
    global [val list_size [int 10]]
    
    loop [val index [int 1]] {
        global [val indices [concat $indices "," $index]] -override
        if [$index | lt $list_size] {
            recur [$index | plus 1]
        }
    }
    
    $indices | split -sep "," | foreach [val item] {
        with [get-editor "test.c" | get-text-viewer] {
            try {
                get-property [concat "markers['" $item "'][0].Type"]
                 | equals "text-to-verify" | verify-true
            }
            -catch {
                // You will need to fine-tune this catch to not allow every sort of problems
            }
        }
    }
    

    【讨论】:

    • 问题是第一次执行时,数字是1、32和45,但是第二次执行时,数字改变了,因为找不到项目,它实际上失败了。所以我想遍历每个项目以检查该项目是否存在。
    • 或者对我来说如何检查属性的存在也​​会更好。我正在使用 //get-editor "w.c" |获取文本查看器 |获取属性 "markers['31'][0].Type" |get "false" |等于“假”|验证真 // |等于 |验证真实但不工作
    猜你喜欢
    • 2014-05-20
    • 1970-01-01
    • 2016-02-05
    • 1970-01-01
    • 2012-07-08
    • 2014-08-28
    • 1970-01-01
    • 2019-11-03
    • 2018-10-05
    相关资源
    最近更新 更多