Blame specs/lposix_spec.yaml

Packit 437b5e
describe lposix:
Packit 437b5e
- before:
Packit 437b5e
    fcntl, fileno = posix.fcntl, posix.fileno
Packit 437b5e
    O_NONBLOCK = posix.O_NONBLOCK
Packit 437b5e
Packit 437b5e
- context with fcntl F_GETFL:
Packit 437b5e
  - before:
Packit 437b5e
      F_GETFL, F_SETFL = posix.F_GETFL, posix.F_SETFL
Packit 437b5e
Packit 437b5e
      fdin  = fileno (io.stdin)
Packit 437b5e
      flags = fcntl (fdin, F_GETFL)
Packit 437b5e
      restore = flags
Packit 437b5e
  - after:
Packit 437b5e
      fcntl (fdin, F_SETFL, restore)
Packit 437b5e
Packit 437b5e
  - it returns flags as a non-negative number:
Packit 437b5e
      expect (type (flags)).should_be "number"
Packit 437b5e
      expect (flags >= 0).should_be (true)
Packit 437b5e
  - it resets O_NONBLOCK bit, if any:
Packit 437b5e
      fcntl (fdin, F_SETFL, band (flags, bnot (O_NONBLOCK)))
Packit 437b5e
      flags = fcntl (fdin, F_GETFL)
Packit 437b5e
      expect (band (flags, O_NONBLOCK)).should_be (0)
Packit 437b5e
  - it sets O_NONBLOCK bit:
Packit 437b5e
      fcntl (fdin, F_SETFL, bor (flags, O_NONBLOCK))
Packit 437b5e
      flags = fcntl (fdin, F_GETFL)
Packit 437b5e
      expect (band (flags, O_NONBLOCK)).should_not_be (0)
Packit 437b5e
  - it returns nil for negative fd argument:
Packit 437b5e
      ret, msg, errno = fcntl (-7, F_GETFL)
Packit 437b5e
      expect (ret).should_be (nil)
Packit 437b5e
  - it returns nil for unopened fd argument:
Packit 437b5e
      ret, msg, errno = fcntl (666, F_GETFL)
Packit 437b5e
      expect (ret).should_be (nil)
Packit 437b5e
  - it diagnoses incorrect userdata argument:
Packit 437b5e
      expect (fcntl ("foobar", F_GETFL)).should_error "int expected"