<commit_before>
import QtTest 1.0
import QtQuick 2.0

import org.jemc.qml.Sockets 1.0

TestCase {
    id: test
    name: "TCPSocket"
    
    TCPSocket {
        id: socket
        host: "www.example.com"
        port: 80
        
        property var response: ""
        property var expected: /HTTP\/[^\n]* OK/
        
        onConnected: write("GET / HTTP/1.1\r\nHost: %1\r\nConnection: close\r\n\r\n".arg(host))
        onRead: response += message
        onDisconnected: {
            test.verify(response!=undefined, "No response received")
            test.verify(response.search(expected)>=0, 
                           "Unrecognized response received: %1".arg(response))
        }
    }
    
    function wait_for_disconnect() { while(socket.state!=0) { wait(0) } }
    
    function test_it() {
        socket.connect()
        wait_for_disconnect()
    }
}<commit_msg>Added verified hook checking in tst_tcp.qml<commit_after>
import QtTest 1.0
import QtQuick 2.0

import org.jemc.qml.Sockets 1.0

TestCase {
    id: test
    name: "TCPSocket"
    
    TCPSocket {
        id: socket
        host: "www.example.com"
        port: 80
        
        property var verified: false
        property var response: ""
        property var expected: /HTTP\/[^\n]* OK/
        
        onConnected: write("GET / HTTP/1.1\r\nHost: %1\r\nConnection: close\r\n\r\n".arg(host))
        onRead: response += message
        onDisconnected: {
            test.verify(response!=undefined, "No response received")
            test.verify(response.search(expected)>=0, 
                           "Unrecognized response received: %1".arg(response))
            verified = true
        }
    }
    
    function wait_for_disconnect() { while(socket.state!=0) { wait(0) } }
    
    function test_it() {
        socket.connect()
        wait_for_disconnect()
        verify(socket.verified, "Disconnect hook never ran on socket.")
    }
}
{'fraction_non_alphanumeric': 0.12002069322296947, 'fraction_numerical': 0.015519917227108122, 'mean_word_length': 1.9347496206373294, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7344358', 'n_tokens_mistral': 610, 'n_tokens_neox': 599, 'n_words': 130}