<commit_before>var mdns = require('./')
var tape = require('tape')
var dgram = require('dgram')

var port = function (cb) {
  var s = dgram.createSocket('udp4')
  s.bind(0, function () {
    var port = s.address().port
    s.on('close', function () {
      cb(port)
    })
    s.close()
  })
}

var test = function (name, fn) {
  tape(name, function (t) {
    port(function (p) {
      fn(mdns({ip: '127.0.0.1', port: p, multicast: false}), t)
    })
  })
}

test('works', function (dns, t) {
  t.plan(3)

  dns.once('query', function (packet) {
    t.same(packet.type, 'query')
    dns.destroy(function () {
      t.ok(true, 'destroys')
    })
  })

  dns.query('hello-world', function () {
    t.ok(true, 'flushed')
  })
})

test('ANY query', function (dns, t) {
  dns.once('query', function (packet) {
    t.same(packet.questions.length, 1, 'one question')<commit_msg>Test for unwanted warnings<commit_after>var mdns = require('./')
var tape = require('tape')
var dgram = require('dgram')

var port = function (cb) {
  var s = dgram.createSocket('udp4')
  s.bind(0, function () {
    var port = s.address().port
    s.on('close', function () {
      cb(port)
    })
    s.close()
  })
}

var test = function (name, fn) {
  tape(name, function (t) {
    port(function (p) {
      var dns = mdns({ip: '127.0.0.1', port: p, multicast: false})
      dns.on('warning', function (e) {
        t.error(e)
      })
      fn(dns, t)
    })
  })
}

test('works', function (dns, t) {
  t.plan(3)

  dns.once('query', function (packet) {
    t.same(packet.type, 'query')
    dns.destroy(function () {
      t.ok(true, 'destroys')
    })
  })

  dns.query('hello-world', function () {
    t.ok(true, 'flushed')
  })
})

test('ANY query', function (dns, t) {
  dns.once('query', function (packet) {
    t.same(packet.questions.length, 1, 'one question')
{'fraction_non_alphanumeric': 0.20304017372421282, 'fraction_numerical': 0.010857763300760043, 'mean_word_length': 2.8718487394957983, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '3028745', 'n_tokens_mistral': 725, 'n_tokens_neox': 711, 'n_words': 151}