This file is indexed.

/usr/lib/ruby/1.8/qttest/qttest.rb is in ruby-qt4-test 4:4.8.2-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
=begin
/***************************************************************************
                          qttest.rb  -  QtTest ruby client lib
                             -------------------
    begin                : 29-10-2008
    copyright            : (C) 2008 by Richard Dale
    email                : richard.j.dale@gmail.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
=end

module QtTest
  module Internal
    def self.init_all_classes
      getClassList.each do |c|
        classname = Qt::Internal::normalize_classname(c)
        id = Qt::Internal::findClass(c);
        Qt::Internal::insert_pclassid(classname, id)
        Qt::Internal::cpp_names[classname] = c
        klass = Qt::Internal::isQObject(c) ? Qt::Internal::create_qobject_class(classname, Qt)  : Qt::Internal::create_qt_class(classname, Qt)
        Qt::Internal::classes[classname] = klass unless klass.nil?
      end
    end
  end
end

module Qt
  class Test < Base
      
    # This is the isValidSlot() function in testlib/qtestcase.cpp translated
    # to Ruby. Probably could be a bit shorter in Ruby..
    def self.validSlot?(sl)
      if sl.access != Qt::MetaMethod::Private || !sl.parameterTypes.empty? ||
         sl.typeName != "" || sl.methodType != Qt::MetaMethod::Slot
        return false
      end
      
      sig = sl.signature
      len = sig.length
      
      if len < 2
        return false
      end
      
      if sig[len - 2, 1] != '(' || sig[len - 1, 1] != ')'
        return false
      end
      
      if len > 7 && sig[len - 7, len] == "_data()"
        return false
      end
      
      if sig == "initTestCase()" || sig == "cleanupTestCase()" ||
         sig == "cleanup()" || sig == "init()"
        return false
      end

      return true
    end
    
    def self.current_binding
        @@current_binding
    end
    
    def self.current_binding=(b)
        @@current_binding = b
    end
    
    def self.qExec(*args)
      test_functions = []
      meta = args[0].metaObject
      className = meta.className
      for i in 0...meta.methodCount
        sl = meta.method(i)
        if Test.validSlot?(sl)
            test_functions << sl.signature.sub("()", "").to_sym
        end
      end
      
      # Trap calls to the test functions and save their binding, so that
      # the various test methods, like QVERIFY(), can evaluate the code strings
      # passed to them in the context of the test function
      trace_func = set_trace_func proc { |event, file, line, id, binding, klass|
        if event == 'call' && klass.name == className && test_functions.include?(id)
          Test.current_binding = binding
        end
      }
      
      if args.length == 2 && args[1].kind_of?(Array)
        super(args[0], args[1].length + 1, [$0] + args[1])
      else
        super(*args)
      end
      
      set_trace_func(trace_func)
    end
  end 

  class Base
    def QVERIFY(statement)
      file, line = caller(1)[0].split(':')
      if !Qt::Test.qVerify(eval(statement, Qt::Test.current_binding), statement, "", file, line.to_i)
          return eval('return', Qt::Test.current_binding)
      end
    end
    
    def QFAIL(message)
      file, line = caller(1)[0].split(':')
      Qt::Test.qFail(message, file, line.to_i)
      return eval('return', Qt::Test.current_binding)
    end
    
    def QVERIFY2(statement, description)
      file, line = caller(1)[0].split(':')
      if eval(statement, Qt::Test.current_binding)
        if !Qt::Test.qVerify(true, statement, description, file, line.to_i)
          return eval('return', Qt::Test.current_binding)
        end
      else
        if !Qt::Test.qVerify(false, statement, description, file, line.to_i)
          return eval('return', Qt::Test.current_binding)
        end
      end
    end
    
    def QCOMPARE(actual, expected)
      file, line = caller(1)[0].split(':')
      if !Qt::Test.qCompare(eval(actual, Qt::Test.current_binding), eval(expected, Qt::Test.current_binding), actual, expected, file, line.to_i)    
        return eval('return', Qt::Test.current_binding)
      end
    end
    
    def QSKIP(statement, mode)
      file, line = caller(1)[0].split(':')
      Qt::Test.qSkip(statement, mode, file, line.to_i)
      return eval('return', Qt::Test.current_binding)
    end
    
    def QEXPECT_FAIL(dataIndex, comment, mode)
      file, line = caller(1)[0].split(':')
      if !Qt::Test.qExpectFail(dataIndex, comment, mode, file, line.to_i)
        return eval('return', Qt::Test.current_binding)
      end
    end
  
    def QTEST(actual, testElement)
      file, line = caller(1)[0].split(':')
      if !Qt::Test.qTest(eval(actual, Qt::Test.current_binding), eval(testElement, Qt::Test.current_binding), actual, testElement, file, line.to_i)
        return eval('return', Qt::Test.current_binding)
      end
    end
    
    def QWARN(msg)
      Qt::Test.qWarn(msg)
    end
  end
end